Bug 264908

Summary: It does not work to obtain an IP address via DHCP simultaneously for multiple interfaces
Product: Base System Reporter: Vladyslav V. Prodan <admin>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: New ---    
Severity: Affects Only Me CC: net
Priority: ---    
Version: 12.3-STABLE   
Hardware: amd64   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=218191
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=237649
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=187006

Description Vladyslav V. Prodan 2022-06-26 14:13:45 UTC
Given physical server in KimSufi (OVH):
Atom(TM) CPU N2800 @ 1.86GHz, 2 core/4 threads, RAM 4GB, one 2TB HDD, 100Mb network interface (em0)

# uname -a
FreeBSD tank2.storage 12.3-STABLE FreeBSD 12.3-STABLE #0 r372168M: Sat Jun 25 20:34:53 EEST 2022

# uname -KU
1203507 1203507

# ifconfig -l
em0 enc0 lo0 pflog0 pfsync0 ygg0

# sysrc -a | grep -E 'ygg|_em0|DHCP|NOAUTO'
ifconfig_DEFAULT: SYNCDHCP
ifconfig_em0: DHCP
ifconfig_em0_alias0: inet6 2001:XXXX:Y:YYYY::2
ifconfig_em0_ipv6: inet6 2001:XXXX:YYYY:XXXX::1/56
yggdrasil_enable: YES

# grep -v ^# /etc/dhclient.conf

In logs after system start:
...
Jun 26 12:12:05 tank2 kernel: Starting devd.
Jun 26 12:12:05 tank2 kernel: Starting dhclient.
Jun 26 12:12:05 tank2 kernel: ifconfig: ioctl (SIOCAIFADDR): File exists
Jun 26 12:12:05 tank2 kernel: em0: not found
Jun 26 12:12:05 tank2 kernel: exiting.
Jun 26 12:12:05 tank2 kernel: /etc/rc.d/dhclient: WARNING: failed to start dhclient
...
Jun 26 12:12:12 tank2 ntpd[6966]: Soliciting pool server 149.202.91.39
...
Jun 26 15:12:18 tank2 dhclient[65385]: DHCPDISCOVER on ygg0 to 255.255.255.255 port 67 interval 3
...
Jun 26 15:12:21 tank2 dhclient[65385]: DHCPDISCOVER on ygg0 to 255.255.255.255 port 67 interval 4
...
Jun 26 15:18:19 tank2 dhclient[65385]: DHCPDISCOVER on ygg0 to 255.255.255.255 port 67 interval 5
Jun 26 15:18:24 tank2 dhclient[65385]: DHCPDISCOVER on ygg0 to 255.255.255.255 port 67 interval 10
Jun 26 15:18:34 tank2 dhclient[65385]: DHCPDISCOVER on ygg0 to 255.255.255.255 port 67 interval 11
Jun 26 15:18:45 tank2 dhclient[65385]: DHCPDISCOVER on ygg0 to 255.255.255.255 port 67 interval 12
Jun 26 15:18:47 tank2 ntpd[6966]: Soliciting pool server 162.159.200.123
Jun 26 15:18:57 tank2 dhclient[65385]: DHCPDISCOVER on ygg0 to 255.255.255.255 port 67 interval 14
Jun 26 15:19:11 tank2 dhclient[65385]: DHCPDISCOVER on ygg0 to 255.255.255.255 port 67 interval 9
Jun 26 15:19:20 tank2 dhclient[65385]: No DHCPOFFERS received.
Jun 26 15:19:20 tank2 dhclient[65385]: No working leases in persistent database - sleeping.
...

The NTP server on v6 gets the right time, so the time stamp jumped to 3 hours


I try to manually get network settings via DHCP:
# dhclient enc0
ifconfig: ioctl (SIOCAIFADDR): Invalid argument
enc0: not found
exiting.

# dhclient em0
ifconfig: ioctl (SIOCAIFADDR): File exists
em0: not found
exiting.

Network settings haven't changed since 12.2-STABLE.


As a solution to the problem, adding lines to rc.conf and reboot helps:
ifconfig_enc0="NOAUTO"
ifconfig_ygg0="NOAUTO"


How to reproduce the issue.

Create a FreeBSD 12.3-STABLE (virtual) machine with more than one network interface that receives network settings.
Add lines to rc.conf config:
ifconfig_DEFAULT="SYNCDHCP"
ifconfig_em0="DHCP"

Reboot machine.
Comment 1 Vladyslav V. Prodan 2022-06-27 07:01:24 UTC
I need a mechanism to maintain availability in a virtual machine and not only when network settings are not set on network interfaces.
Many network interfaces can be added to the virtual machine template, since Proxmox has one of the popular methods of vlan isolation.

I find a mechanism for solving my problem - in rc.conf:
ifconfig_DEFAULT="SYNCDHCP"

But! Between reading rc.conf and starting dhclient, which tries network settings on all available network interfaces, it takes some time.
During this time, tunnel services manage to start up and add their network interfaces to the system.

Specifically, in my case, you need to set exceptions through the settings ifconfig_ygg0="NOAUTO"

My old kernel from 12.2-STABLE on r369446 didn't have this situation.
Reboot took place regularly and the correct network settings were issued via DHCP on the em0 interface.