Bug #12632
closedChanging an interface IP address and gateway at the console does not save the new gateway if one already exists for the interface
100%
Description
First encoutnered two months ago. Assumed I had done a typo or something and moved on. Now notice this can be reproduced every time on all installs I have tried:
ISP / Colo assign an IPv4 /30 203.0.113.156/30
Hardware has two NICs. bxe0 and bxe1. bxe0 is WAN bxe1 has no link.
- Install pfSense 2.5.2
- Assign bxe0 as WAN via console menu option 1
- Do not assign bxe1 as anything.
- Assign WAN IP manually via console menu option 2
- Specify: WAN IP 203.0.113.158, Netmask 30, Gateway 203.0.113.157
Expected behavior: Default route should be set with gateway as 203.0.113.157
Actual behavior: Gateway revers to 203.0.113.158, networking becomes impossible
Workaround:
- route del default
- route add default 203.0.113.157
- Enter web configurator
- Notice here during the WAN configuration step in web configurator it does indeed show gateway incorrectly as 203.0.113.158
- Fix gateway in web configurator
- Apply
Only ever seen this when WAN is a /30 - /22 /23/24 etc do not do this.
Files
Updated by Viktor Gurov about 3 years ago
- Status changed from New to Feedback
- Affected Version set to 2.5.2
Unable to reproduce:
Available interfaces: 1 - WAN (vtnet1 - dhcp, dhcp6) 2 - LAN (vtnet0 - static) 3 - OPT1 (vtnet2 - static, staticv6) Enter the number of the interface you wish to configure: 1 Configure IPv4 address WAN interface via DHCP? (y/n) n Enter the new WAN IPv4 address. Press <ENTER> for none: > 203.0.113.158 Subnet masks are entered as bit counts (as in CIDR notation) in pfSense. e.g. 255.255.255.0 = 24 255.255.0.0 = 16 255.0.0.0 = 8 Enter the new WAN IPv4 subnet bit count (1 to 31): > 30 For a WAN, enter the new WAN IPv4 upstream gateway address. For a LAN, press <ENTER> for none: > 203.0.113.157
result:
# route -4n get default route to: 0.0.0.0 destination: 0.0.0.0 mask: 0.0.0.0 gateway: 203.0.113.157 fib: 0 interface: vtnet1 flags: <UP,GATEWAY,DONE,STATIC> recvpipe sendpipe ssthresh rtt,msec mtu weight expire 0 0 0 0 1500 1 0
Updated by Viktor Gurov almost 3 years ago
seems to be fixed in #11581
please test on the latest development snapshot
Updated by Danilo Zrenjanin almost 3 years ago
- File clipboard-202112311307-sidpz.png clipboard-202112311307-sidpz.png added
- Status changed from Feedback to Resolved
Tested against:
2.6.0-BETA (amd64) built on Thu Dec 30 06:16:46 UTC 2021 FreeBSD 12.3-STABLE
It works as expected. I am marking this ticket resolved.
Updated by Danilo Zrenjanin almost 3 years ago
- Status changed from Resolved to Feedback
- Priority changed from Normal to High
Updated by Danilo Zrenjanin almost 3 years ago
I tested again, against the same version:
2.6.0-BETA (amd64) built on Thu Dec 30 06:16:46 UTC 2021 FreeBSD 12.3-STABLE
This time I didn't have the default gateway in the routing table after setting WAN IP 203.0.113.158, Netmask 30, Gateway 203.0.113.157 from the console.
It's strange it doesn't fail every time.
Needs more testing.
Available interfaces: 1 - WAN (vtnet0 - dhcp) 2 - LAN (vtnet1.20 - static) Enter the number of the interface you wish to configure: 1 Configure IPv4 address WAN interface via DHCP? (y/n) n Enter the new WAN IPv4 address. Press <ENTER> for none: > 203.0.113.158 Subnet masks are entered as bit counts (as in CIDR notation) in pfSense. e.g. 255.255.255.0 = 24 255.255.0.0 = 16 255.0.0.0 = 8 Enter the new WAN IPv4 subnet bit count (1 to 32): > 30 For a WAN, enter the new WAN IPv4 upstream gateway address. For a LAN, press <ENTER> for none: > 203.0.113.157 Configure IPv6 address WAN interface via DHCP6? (y/n) n Enter the new WAN IPv6 address. Press <ENTER> for none: > Disabling IPv4 DHCPD... Disabling IPv6 DHCPD... Do you want to revert to HTTP as the webConfigurator protocol? (y/n) n Please wait while the changes are saved to WAN... Reloading filter... Reloading routing configuration...route: writing to routing socket: Network is unreachable DHCPD... The IPv4 WAN address has been set to 203.0.113.158/30 Press <ENTER> to continue.
[2.6.0-BETA][admin@pfSense.home.arpa]/root: route -n get default route: route has not been found
[2.6.0-BETA][admin@pfSense.home.arpa]/root: netstat -rn Routing tables Internet: Destination Gateway Flags Netif Expire 127.0.0.1 link#4 UH lo0 192.168.20.0/24 link#7 U vtnet1.2 192.168.20.2 link#7 UHS lo0 203.0.113.156/30 link#1 U vtnet0 203.0.113.158 link#1 UHS lo0
Updated by Danilo Zrenjanin almost 3 years ago
I replicated the issue on 22.01.r.20220124.1828 and 2.6.0.r.20220124.1828.
Available interfaces: 1 - WAN (lagg0.4090 - dhcp) 2 - LAN (lagg0.4091 - static) 3 - OPT1 (ix0) 4 - OPT2 (ix1) Enter the number of the interface you wish to configure: 1 Configure IPv4 address WAN interface via DHCP? (y/n) n Enter the new WAN IPv4 address. Press <ENTER> for none: > 203.0.113.158 Subnet masks are entered as bit counts (as in CIDR notation) in Netgate pfSense Plus. e.g. 255.255.255.0 = 24 255.255.0.0 = 16 255.0.0.0 = 8 Enter the new WAN IPv4 subnet bit count (1 to 32): > 30 For a WAN, enter the new WAN IPv4 upstream gateway address. For a LAN, press <ENTER> for none: > 203.0.113.157 Configure IPv6 address WAN interface via DHCP6? (y/n) n Enter the new WAN IPv6 address. Press <ENTER> for none: > Disabling IPv4 DHCPD... Disabling IPv6 DHCPD... Do you want to revert to HTTP as the webConfigurator protocol? (y/n) n Please wait while the changes are saved to WAN... Reloading filter... Reloading routing configuration...route: writing to routing socket: Network is unreachable DHCPD... The IPv4 WAN address has been set to 203.0.113.158/30 Press <ENTER> to continue.
netstat -rn Routing tables Internet: Destination Gateway Flags Netif Expire 127.0.0.1 link#16 UH lo0 192.168.1.0/24 link#21 U lagg0.40 192.168.1.1 link#21 UHS lo0 203.0.113.156/30 link#20 U lagg0.40 203.0.113.158 link#20 UHS lo0
It looks like it fails to write the default gateway if it is not reachable when defining it from the console.
Updated by Jim Pingle almost 3 years ago
- Subject changed from 2.5.2 New installs, when assigning WAN IP from a /30 gateway is saved incorrectly. to Assigning a /30 WAN IP address at the console does not save the gateway correctly
- Status changed from Feedback to New
- Target version set to 2.7.0
- Plus Target Version set to 22.05
Updated by Jim Pingle over 2 years ago
- Plus Target Version changed from 22.05 to 22.09
Updated by Jim Pingle over 2 years ago
- Plus Target Version changed from 22.09 to 22.11
Updated by Jim Pingle about 2 years ago
- Plus Target Version changed from 22.11 to 23.01
Updated by Jim Pingle about 2 years ago
- Status changed from New to In Progress
I see a couple problems here.
First, the script only sets the default gateway if there is no default gateway set -- so it's behaving as it's coded, but not how it's expected here. I'll change that so it prompts the user about replacing the default instead of the current behavior.
Second there are some faulty assumptions made by the script about WAN type vs LAN type interfaces, and in some places it has hardcoded "wan" and "lan" which means some parts are broken for OPT interfaces, which is somewhat related to how it's breaking here since the behavior is even more questionable if you try to reproduce this bug on an OPT interface.
Updated by Jim Pingle about 2 years ago
- Status changed from In Progress to Feedback
- % Done changed from 0 to 100
Applied in changeset 13ae614b25433193c5bab8beabff65a1c80dcb3a.
Updated by Alhusein Zawi about 2 years ago
WAN IP and the default GW have been assigned via the console and the the default route has been added
First, the script only sets the default gateway if there is no default gateway set -- so it's behaving as it's coded, but not how it's expected here. I'll change that so it prompts the user about replacing the default instead of the current behavior.
changed the IP and the GW via the console but I did not see prompts about replacing
23.01-DEVELOPMENT (amd64)
built on Fri Nov 18 06:04:48 UTC 2022
FreeBSD 14.0-CURRENT
Updated by Jim Pingle about 2 years ago
- Subject changed from Assigning a /30 WAN IP address at the console does not save the gateway correctly to Changing an interface IP address and gateway at the console does not save the new gateway if one already exists for the interface
Updating subject for release notes.
Updated by Jim Pingle about 2 years ago
- Category changed from Gateways to Console Menu
Updated by Jim Pingle about 2 years ago
- Status changed from Feedback to Resolved
Seems to be doing the right/expected thing. It prompts to set the default gateway and does so when instructed.
Enter an option: 2 Available interfaces: 1 - wan (vtnet0 - dhcp, dhcp6) 2 - lan (vtnet1 - static) 3 - OPT1 (vtnet2) Enter the number of the interface you wish to configure: 3 Configure IPv4 address OPT1 interface via DHCP? (y/n) n Enter the new OPT1 IPv4 address. Press <ENTER> for none: > 10.34.123.2/30 For a WAN, enter the new OPT1 IPv4 upstream gateway address. For a LAN, press <ENTER> for none: > 10.34.123.1 Should this gateway be set as the default gateway? (y/n) y Configure IPv6 address OPT1 interface via DHCP6? (y/n) n Enter the new OPT1 IPv6 address. Press <ENTER> for none: > Do you want to enable the DHCP server on OPT1? (y/n) n Do you want to revert to HTTP as the webConfigurator protocol? (y/n) n Please wait while the changes are saved to OPT1... Reloading filter... Reloading routing configuration... The IPv4 OPT1 address has been set to 10.34.123.2/30 Press <ENTER> to continue.
Then afterward it's set as the default and in the routing table.
Note: the new prompt is this one:
Should this gateway be set as the default gateway?