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

Changing default gateway leaves 2 default gateways in config

2.1 Snapshot Feedback and Problems - RETIRED
5
9
2.9k
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.
  • P
    phil.davis
    last edited by Apr 5, 2013, 7:21 AM

    This has been a "feature" for as long as I have been involved in pfSense. On a simple system, LAN, WAN, OPT1, WAN is default gateway. Edit OPT1 gateway, select "Default gateway", and save. The default route switches to the OPT1 gateway IP (good). But in the config both WAN and OPT1 are enabled as default gateway. They both show (default) on the GUI. The user has to also edit WAN, uncheck "Default Gateway" and save.
    There should only ever be 1 default gateway, shouldn't there?
    When editing a gateway and "Default Gateway" is checked, the code should automatically deselect "Default Gateway" on the gateway that is currently the default gateway?
    Or am I missing something?
    (Sometimes when I do this change of default gateways I have end up with no default route in the routing table - it happened to me this morning. But now I can't reproduce it on a test system, I have swapped back and forth a few times and the default route in the routing table is faithfully following the latest gateway selected as default route.)

    As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
    If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

    1 Reply Last reply Reply Quote 0
    • C
      cmb
      last edited by Apr 5, 2013, 8:10 AM

      I've heard that before but we've never been able to replicate it. When you mark some other gateway as default, it un-marks the previous default gateway. There's apparently some unusual circumstance in which it doesn't but no idea what that might be or how to replicate it. If you can find the magic circumstance where it's replicable that'd be helpful.

      1 Reply Last reply Reply Quote 0
      • P
        phil.davis
        last edited by Apr 5, 2013, 11:15 AM

        I think it is because 1 gateway is DHCP and the other has static IPv4. I guess the same problem would happen if both gateways are DHCP. Quickly looking at the code in system_gateways_edit.php, it only does the unset if both the gateway being modified and the gateway being checked in the loop have a proper IPv4 address. If the gateway setting is "dynamic" then that test won't work. It needs looking at to then see how to work out if the gateway is an IPv4 or IPv6 gateway_item (or can 1 gateway_item have both an IPv4 and IPv6 address? I haven't looked into all that). Looks like the same issue will happen for IPv6 gateways that are one of the "dynamic/DHCP" types.

        			/* remove the default gateway bits for all gateways with the same address family */
        			foreach($a_gateway_item as $gw) {
        				if(is_ipaddrv4($gateway['gateway']) && is_ipaddrv4($gw['gateway'])) {
        					unset($config['gateways']['gateway_item'][$i]['defaultgw']);
        					if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
        						$reloadif = $gw['interface'];
        				}
        				if(is_ipaddrv6($gateway['gateway']) && is_ipaddrv6($gw['gateway'])) {
        					unset($config['gateways']['gateway_item'][$i]['defaultgw']);
        					if ($gw['interface'] != $_POST['interface'] && $gw['defaultgw'])
        						$reloadif = $gw['interface'];
        				}
        				$i++;
        			}
        			$gateway['defaultgw'] = true;
        

        As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
        If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

        1 Reply Last reply Reply Quote 0
        • G
          ggzengel
          last edited by Apr 5, 2013, 1:41 PM

          All my pfsense 2.1 have this.

          I thought it's for load balancing:

          Allow default gateway switching
          If the link where the default gateway resides fails switch the default gateway to another available one.

          Does that means that load balacing switch to any gateway?
          Does it switch back?

          I asked this question once befor.

          1 Reply Last reply Reply Quote 0
          • M
            Maksimka
            last edited by Apr 5, 2013, 10:51 PM

            I have an issue where my openvpn gateway interface is acting as default gateway even though my wan is set as default.  Is this the same problem?  I just switched from 2.0.

            1 Reply Last reply Reply Quote 0
            • P
              phil.davis
              last edited by Apr 6, 2013, 1:23 AM

              In System->Routing you should be able to edit the gateways that you do NOT want to be the default, uncheck "Default Gateway", save. That should get rid of the extra default gateways. Make sure to leave 1 useful default gateway ;)

              As the Greek philosopher Isosceles used to say, "There are 3 sides to every triangle."
              If I helped you, then help someone else - buy someone a gift from the INF catalog http://secure.inf.org/gifts/usd/

              1 Reply Last reply Reply Quote 0
              • X
                xbipin
                last edited by Apr 6, 2013, 5:33 AM

                well, i faced this and reported also earlier, might not be exactly same but its related to default gateway switching etc

                http://forum.pfsense.org/index.php/topic,59697.0.html

                1 Reply Last reply Reply Quote 0
                • C
                  cmb
                  last edited by Apr 6, 2013, 8:57 AM

                  @phil.davis:

                  I think it is because 1 gateway is DHCP and the other has static IPv4. I guess the same problem would happen if both gateways are DHCP. Quickly looking at the code in system_gateways_edit.php, it only does the unset if both the gateway being modified and the gateway being checked in the loop have a proper IPv4 address. If the gateway setting is "dynamic" then that test won't work. It needs looking at to then see how to work out if the gateway is an IPv4 or IPv6 gateway_item

                  Yeah that's it. It shouldn't be checking IP, it should check <ipprotocol>within that gateway entry. If any other gateway with the same <ipprotocol>has defaultgw set, unset it. I think the reason for that is a bug left over from before <ipprotocol>existed in the gateways entries.</ipprotocol></ipprotocol></ipprotocol>

                  1 Reply Last reply Reply Quote 0
                  • M
                    Maksimka
                    last edited by Apr 6, 2013, 4:18 PM

                    @phil.davis:

                    In System->Routing you should be able to edit the gateways that you do NOT want to be the default, uncheck "Default Gateway", save. That should get rid of the extra default gateways. Make sure to leave 1 useful default gateway ;)

                    I know.  My wan gateway is the only marked at default, but it's not be using as default.  It will only default when I disable my the other gateway.

                    1 Reply Last reply Reply Quote 0
                    1 out of 9
                    • First post
                      1/9
                      Last post
                    Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.