• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Is changing the localhost (127.0.0.1) gateway possible?

Scheduled Pinned Locked Moved Routing and Multi WAN
10 Posts 3 Posters 1.5k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J
    Jimbo123
    last edited by Jan 21, 2020, 6:56 PM

    Hi guys, I have a question out of curiosity more than anything. In the manual/advanced NAT tab of my firewall I have a default rule for localhost (127.0.0.1) that shows localhost traffic is routed out the WAN gateway by default. I am not currently having any issues with this but I was wondering if it is possible to change the localhost gateway? Localhost is not listed as an interface so policy routing is not possible via the interfaces tab or the floating rules tab. I'm aware floating rules can filter traffic from the firewall itself but can they route traffic from it?

    1 Reply Last reply Reply Quote 0
    • V
      viragomann
      last edited by Jan 21, 2020, 7:12 PM

      It uses the default gateway.
      You may set another gateway as default if you want.

      1 Reply Last reply Reply Quote 0
      • J
        jimp Rebel Alliance Developer Netgate
        last edited by Jan 21, 2020, 7:14 PM

        Outbound NAT does not influence where traffic goes. It only defines what happens to traffic which happens to exit out those interfaces.

        So those rules do not tell traffic from localhost to exit WAN
        They say "If traffic from localhost happens to exit WAN, then apply this translation"

        Routing is controlled by gateways, under System > Routing.

        Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

        Need help fast? Netgate Global Support!

        Do not Chat/PM for help!

        1 Reply Last reply Reply Quote 0
        • J
          Jimbo123
          last edited by Jan 21, 2020, 7:27 PM

          Hi, yes I'm aware of this. I just noticed that the localhost NAT rule allows traffic out the WAN interface by default. I just wondered if there was a way to route the traffic out a different interface and change/add a the NAT rule accordingly.

          1 Reply Last reply Reply Quote 0
          • J
            jimp Rebel Alliance Developer Netgate
            last edited by Jan 21, 2020, 7:35 PM

            NAT rules do not allow traffic. See my previous reply.

            If you want to route traffic out another interface, then use gateways/routing to do it.

            If the other interface is properly configured as a WAN (that is, has a gateway set on its interface configuration), then automatic outbound NAT should setup rules for it automatically. You should not need to touch anything in outbound NAT if it's on automatic. If you are on manual outbound NAT, then you may need to copy the existing localhost rules to the new WAN. But in most cases that's not necessary.

            Also traffic from the firewall itself is not typically sourced from "localhost". That rule is there to ensure that should it happen to be, that it gets NAT applied.

            Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

            Need help fast? Netgate Global Support!

            Do not Chat/PM for help!

            J 1 Reply Last reply Jan 21, 2020, 8:05 PM Reply Quote 0
            • J
              Jimbo123 @jimp
              last edited by Jan 21, 2020, 8:05 PM

              @jimp I read your previous reply. I'm aware NAT rules can't direct traffic in any way shape or form. What I meant by allow was that if there is no translation in place for the localhost interface then traffic cannot leave that interface. My question was never about infliuencing traffic using NAT rules. I just made my assumption that the pfSense routes localhost traffic out the WAN because it had a default NAT rule for the localhost IP address that showed that localhost traffic happens to exit WAN. What I asked was "I'm aware floating rules can filter traffic from the firewall itself but can they route traffic from it?" I'm not sure where all this routing traffic using NAT rules has come from.

              1 Reply Last reply Reply Quote 0
              • J
                jimp Rebel Alliance Developer Netgate
                last edited by Jan 21, 2020, 8:18 PM

                What I meant by allow was that if there is no translation in place for the localhost interface then traffic cannot leave that interface.

                But it can. It just won't have its source translated.

                I just made my assumption that the pfSense routes localhost traffic out the WAN because it had a default NAT rule for the localhost IP address that showed that localhost traffic happens to exit WAN.

                Yes, and that's what I was saying isn't right.

                I'm aware floating rules can filter traffic from the firewall itself but can they route traffic from it?

                Policy routing rules won't have a useful effect on traffic from the firewall itself, hence my saying you need to control traffic using gateways and routes under System > Routing.

                Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                Need help fast? Netgate Global Support!

                Do not Chat/PM for help!

                1 Reply Last reply Reply Quote 0
                • J
                  Jimbo123
                  last edited by Jan 21, 2020, 8:42 PM

                  So I would be wrong to assume that pfSense by default routes locahost traffic (if any) out the WAN after noticing the default NAT rule for localhost in place? Sorry I'm just completely confused here. Why would there be such a rule in place if localhost traffic doesnt leave via that gateway by default?

                  But if I deleted the NAT rule on my LAN interface I would not have access to the internet. Does this mean traffic still leaves the WAN interface regardless if there is a NAT rule in place, just that it has no route back?

                  I'm not sure if it comes across like I'm trying to argue with you - I'm not. You are a considerably more knowledgeable on this, I'm just trying to learn.

                  J 1 Reply Last reply Jan 21, 2020, 8:51 PM Reply Quote 0
                  • J
                    jimp Rebel Alliance Developer Netgate @Jimbo123
                    last edited by Jan 21, 2020, 8:51 PM

                    @Jimbo123 said in Is changing the localhost (127.0.0.1) gateway possible?:

                    So I would be wrong to assume that pfSense by default routes locahost traffic (if any) out the WAN after noticing the default NAT rule for localhost in place? Sorry I'm just completely confused here. Why would there be such a rule in place if localhost traffic doesnt leave via that gateway by default?

                    You are drawing incorrect assumptions about NAT and routing here. Just because a NAT rule exists doesn't mean any traffic would ever hit it. It's there in case it does, but one doesn't necessarily imply the other. You could have NAT rules for every interface if you like, but they may never be utilized. If you want to know how traffic is routed, the only way to know that is via routing.

                    So you may have reached a correct conclusion by accident.

                    But if I deleted the NAT rule on my LAN interface I would not have access to the internet.

                    The NAT rule for the LAN network(s), not on the LAN interface, but (probably) correct.

                    Does this mean traffic still leaves the WAN interface regardless if there is a NAT rule in place, just that it has no route back?

                    That is up to your upstream. The traffic exits the WAN no matter what, unless your LAN or floating rules block it. In most cases the traffic would be dropped since the upstream doesn't know about your LAN subnets. If the upstream router was setup with its own NAT and routing back, then it would still function. People use pfSense in this kind of scenario as an internal router with NAT disabled all the time.

                    I'm not sure if it comes across like I'm trying to argue with you - I'm not. You are a considerably more knowledgeable on this, I'm just trying to learn.

                    Sure, and I'm just trying to inform. It's a common misconception that NAT has any influence here, getting over that hurdle early is best.

                    Remember: Upvote with the 👍 button for any user/post you find to be helpful, informative, or deserving of recognition!

                    Need help fast? Netgate Global Support!

                    Do not Chat/PM for help!

                    J 1 Reply Last reply Jan 21, 2020, 9:08 PM Reply Quote 1
                    • J
                      Jimbo123 @jimp
                      last edited by Jan 21, 2020, 9:08 PM

                      @jimp "It's a common misconception that NAT has any influence here, getting over that hurdle early is best." I'm glad you brought it up, I've got the answer to my original question and I've learned how NAT actually works which was something I thought I already knew. Thanks @jimp

                      1 Reply Last reply Reply Quote 0
                      10 out of 10
                      • First post
                        10/10
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                        This community forum collects and processes your personal information.
                        consent.not_received