Bug 277904 - DHCP and static ip not correctly configured
Summary: DHCP and static ip not correctly configured
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: 14.0-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-rc (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-23 09:43 UTC by crb
Modified: 2024-03-28 12:06 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description crb 2024-03-23 09:43:07 UTC
I have the following line in my /etc/rc.conf:

ifconfig_bge0="DHCP"
ifconfig_bge0_alias0="99.104.201.113/29"
ifconfig_bge0_ipv6="inet6 accept_rtadv"

If I reboot with this, upon restart ifconfig reports the following:

bge0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
	options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
	ether c4:2c:03:0b:9d:f6
	inet 192.168.1.48 netmask 0xffffff00 broadcast 192.168.1.255
	inet6 fe80::c62c:3ff:fe0b:9df6%bge0 prefixlen 64 scopeid 0x1
	inet6 2600:1700:5430:10b1:c62c:3ff:fe0b:9df6 prefixlen 64 autoconf pltime 604800 vltime 2592000
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
	nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
	options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
	groups: lo
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>

Note that only the DHCP address is present not the static IP of 99.104.201.113/31
If I immediately run "service netif restart;ifconfig" as root I get the following output:

# service netif restart ; ifconfig
Stopping dhclient.
Stopping Network: lo0 bge0.
lo0: flags=8048<LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
	groups: lo
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
bge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
	ether c4:2c:03:0b:9d:f6
	media: Ethernet autoselect
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
/etc/rc.d/netif: WARNING: $ifconfig_bge0_alias0 needs leading "inet" keyword for an IPv4 address.
Starting Network: lo0 bge0.
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
	options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
	groups: lo
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
bge0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
	options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
	ether c4:2c:03:0b:9d:f6
	inet 192.168.1.48 netmask 0xffffff00 broadcast 192.168.1.255
	inet 99.104.201.113 netmask 0xfffffff8 broadcast 99.104.201.119
	inet6 fe80::c62c:3ff:fe0b:9df6%bge0 prefixlen 64 scopeid 0x1
	inet6 2600:1700:5430:10b1:c62c:3ff:fe0b:9df6 prefixlen 64 autoconf pltime 604800 vltime 2592000
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
	nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
bge0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
	options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
	ether c4:2c:03:0b:9d:f6
	inet 192.168.1.48 netmask 0xffffff00 broadcast 192.168.1.255
	inet 99.104.201.113 netmask 0xfffffff8 broadcast 99.104.201.119
	inet6 fe80::c62c:3ff:fe0b:9df6%bge0 prefixlen 64 scopeid 0x1
	inet6 2600:1700:5430:10b1:c62c:3ff:fe0b:9df6 prefixlen 64 autoconf pltime 604800 vltime 2592000
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
	nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
	options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
	groups: lo
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>


Note the final ifconfig lists both the DHCP address and the Static IP.
Fro this I conclude that the configuration in /etc/rc.conf is correct but for some reason doesn't work correctly at start up.  I'm still trying to read startup script to understand why.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2024-03-24 02:42:16 UTC
AFAICT this is a problem in the rc scripts.  Try assigning it to rc@ to see if anyone agrees.
Comment 2 Oleksandr Kryvulia 2024-03-26 19:37:31 UTC
(In reply to crb from comment #0)
Does it reproduces with ifconfig_bge0="SYNCDHCP"?
Comment 3 crb 2024-03-26 19:45:41 UTC
I now have 

ifconfig_bge0="SYNCDHCP"
ifconfig_bge0_alias0="inet alias 99.104.201.113/29"

and that seems to work:

bge0: flags=1008843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST,LOWER_UP> metric 0 mtu 1500
	options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE>
	ether c4:2c:03:0b:9d:f6
	inet 192.168.1.48 netmask 0xffffff00 broadcast 192.168.1.255
	inet 99.104.201.113 netmask 0xfffffff8 broadcast 99.104.201.119
	inet6 fe80::c62c:3ff:fe0b:9df6%bge0 prefixlen 64 scopeid 0x1
	inet6 2600:1700:5430:10b1:c62c:3ff:fe0b:9df6 prefixlen 64 autoconf pltime 604800 vltime 2592000
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
	nd6 options=23<PERFORMNUD,ACCEPT_RTADV,AUTO_LINKLOCAL>
lo0: flags=1008049<UP,LOOPBACK,RUNNING,MULTICAST,LOWER_UP> metric 0 mtu 16384
	options=680003<RXCSUM,TXCSUM,LINKSTATE,RXCSUM_IPV6,TXCSUM_IPV6>
	inet 127.0.0.1 netmask 0xff000000
	inet6 ::1 prefixlen 128
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x2
	groups: lo
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>


Is SYNCDHCP documented anywhere?
Comment 4 Oleksandr Kryvulia 2024-03-27 06:54:19 UTC
Yes, rc.conf(5)
Comment 5 crb 2024-03-27 17:17:28 UTC
I don't know if it's a bug that SYNCDHCP works but DHCP doesn't.  I understand that DHCP doesn't wait for the interface to come up, but I think it shouldn't fail to configure the interface all together.  Perhaps there is some interaction because I have both a DHCP and a static IP.  Perhaps the static IP is configured after the DHCP is started and interrupts that process I don't know, but I don't think it should fail.  If you agree then this is a real bug report with the configuration scripts, if you don't, then my problem is solved and this can be closed.

Either way, thank you for the fantastic software and the help!
Christopher
Comment 6 Oleksandr Kryvulia 2024-03-28 12:06:33 UTC
When dhclient configures interface it removes all IP adresses from it.
With SYNCDHCP rc susbsystem waits while dhclient receives IP and configure it on interface. Then it assigns an alias IP. If you do later "service dhclient restart bge0" you can see that an alias IP is no longer present on interface. IMHO, the proper way to configure static IP with DHCP is to use alias section in /etc/dhclient.conf, please see dhclient.conf(5) for details:

alias {
                interface "bge0";
                fixed-address 99.104.201.113;
                option subnet-mask 255.255.255.248;

}

So I think it works as intended.