Some years ago I made a trip to Fishlake National Forest in Utah on my motorcycle. I used to enjoy solo getaways. One afternoon while I was wandering around, a Ford Bronco approached and a Park Ranger got out. After exchanging some small talk, he asked if I was armed. I showed him my Ruger Super Blackhawk. He said that was good, because it's not safe out here after dark. I told him I had a room at the Fish Lake Lodge and thanked him for his concern. He repeated that he was happy to see that I came prepared.
Google Fishlake National Forest if you are looking for a great unknown vacation spot. If you like rustic splendor.
That would have been a Forest Ranger not a Park Ranger. Firearms have never been prohibited in National Forests except in specific locations like campgrounds in specific Forest districts.
What I'm really curious about from your post is what danger the Ranger was cautioning you about. Two legged or four legged?