Solved [SOLVED] mfsBSD interface not obtaining dhcp address on boot

Hello, I apologize in advance if this is not the best board for this topic but I thought it fit most in networking.

Essentially we have a custom version of FreeBSD8 in our organization which we install via a PXE server to all new computers that we provision.

To install this custom FreeBSD on the machines, the PXE server boots a mfsBSD .iso image which then should obtain an IP via DHCP (there is a DHCP server running on the PXE server) and then automatically fun /etc/rc.local which fetches a script from the PXE server to begin the installation.

The problem is that when mfsBSD boots, I can see the interface within ifconfig (let's just say the interface is em0) but it has no IP.

I then get kicked down to a root prompt in mfsBSD where I have to manually run dhclient em0 and then re-run /etc/rc.local to start the installation.

This seems simple enough but it is a pain to have to babysit the computer until it reaches the prompt. What we are going for here is a fully automatic installation requiring no user intervention.

So my question remains, why is the mfsBSD OS not obtaining an IP from DHCP automatically? Is there perhaps some timeout variable set that only tries to grab an IP from DHCP once and if it fails it does not retry? I have extracted the mfsBSD .iso image and began snooping myself but to no prevail.

If anybody knows what could be causing this I would really appreciate it! Or if there is some workaround script I could employ that would also be helpful. I thought of putting an extra line in /etc/rc.local that reads dhclient em0 but that will not work on a system that has a different interface name :\

Thanks!
 
Re: mfsBSD interface not obtaining dhcp address on boot

Some NICs take a long time to go from "link up" to "link ready" (em and igb being some of the "worst" offenders). If dhclient timesout before the link is ready, you run into the situation you describe.

You can work around it using the netwait script/features in rc.conf(5). That will pause the boot process to wait for the network link to become ready, and usable. The simplest setup (that would work across NIC drivers) would be to add the following to /etc/rc.conf:
Code:
netwait_enable="YES"
netwait_ip="<IP of default gateway for DHCP range"
 
Re: mfsBSD interface not obtaining dhcp address on boot

phoenix said:
Some NICs take a long time to go from "link up" to "link ready" (em and igb being some of the "worst" offenders). If dhclient timesout before the link is ready, you run into the situation you describe.

You can work around it using the netwait script/features in rc.conf(5). That will pause the boot process to wait for the network link to become ready, and usable. The simplest setup (that would work across NIC drivers) would be to add the following to /etc/rc.conf:
Code:
netwait_enable="YES"
netwait_ip="<IP of default gateway for DHCP range"

Hmm tried that and still nothing. it is still not getting an IP on its own.

Is there some way to maybe increase the dhclient timeout (or disable it all-together)
 
Re: mfsBSD interface not obtaining dhcp address on boot

If you run tcpdump() on the DHCP server, or watch the logs on the DHCP server, what packets do you see coming from/going to the client? In the logs, you should see a DHCPDISCOVER from the client, a DHCPOFFER from the server, a DHCPREQUEST from the client, and a DHCPACK from the server.
 
Re: mfsBSD interface not obtaining dhcp address on boot

phoenix said:
If you run tcpdump() on the DHCP server, or watch the logs on the DHCP server, what packets do you see coming from/going to the client? In the logs, you should see a DHCPDISCOVER from the client, a DHCPOFFER from the server, a DHCPREQUEST from the client, and a DHCPACK from the server.

Hi, I ran a tcpdump -i em1 while mfsbsd was booting, here is the output.
Code:
root@jumpstart:/var/log # tcpdump -i em1
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on em1, link-type EN10MB (Ethernet), capture size 65535 bytes
19:40:49.389461 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:40:50.849146 
19:40:51.402789 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:40:51.601983 IP 10.0.0.250.http > 10.0.10.2.blackjack: Flags [FP.], seq 3783054055:3783055161, ack 70243966, win 65535, options [nop,nop,TS val 2218761719 ecr 828350], length 1106
19:40:53.416116 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:40:55.429319 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:40:57.442523 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:40:59.455852 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:40:59.485527 IP 10.0.0.250.http > 10.0.10.2.blackjack: Flags [FP.], seq 0:1106, ack 1, win 65535, options [nop,nop,TS val 2218769602 ecr 828350], length 1106
19:41:00.849080 
19:41:01.469181 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:41:03.482383 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:41:05.495711 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:41:07.509040 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:41:08.339005 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 18:03:73:b9:f8:be (oui Unknown), length 300
19:41:08.339099 IP 10.0.0.250 > 10.0.10.7: ICMP echo request, id 32770, seq 0, length 28
19:41:09.402526 IP 10.0.0.250.bootps > 10.0.10.7.bootpc: BOOTP/DHCP, Reply, length 300
19:41:09.522244 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:41:10.859757 
19:41:11.404532 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 18:03:73:b9:f8:be (oui Unknown), length 300
19:41:11.405424 IP 10.0.0.250.bootps > 10.0.10.7.bootpc: BOOTP/DHCP, Reply, length 300
19:41:11.406904 ARP, Request who-has 10.0.10.7 tell 10.0.10.7, length 46
19:41:11.411402 ARP, Request who-has 10.0.10.7 tell 10.0.10.7, length 46
19:41:11.535571 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:41:13.548776 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:41:15.087750 IP 10.0.0.250.http > 10.0.10.2.blackjack: Flags [FP.], seq 0:1106, ack 1, win 65535, options [nop,nop,TS val 2218785205 ecr 828350], length 1106
19:41:15.562104 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43
19:41:17.575431 STP 802.1w, Rapid STP, Flags [Learn, Forward], bridge-id 8bba.00:13:60:c0:04:00.8003, length 43

After I was logged in and sitting at the root prompt, and within another 10 seconds I noticed the tcpdump had finally received a DHCP Request and sent an IP 10.0.20.7 as seen in the two lines here
Code:
19:41:11.404532 IP 0.0.0.0.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 18:03:73:b9:f8:be (oui Unknown), length 300
19:41:11.405424 IP 10.0.0.250.bootps > 10.0.10.7.bootpc: BOOTP/DHCP, Reply, length 300

So it seems like the client will eventually receive an IP after letting it sit at the root prompt for another 10-20 seconds, but then I still have to re-run /etc/rc.local and then logout so that I can access the pc-postinstall script.

Is there another way to either delay the execution of /etc/rc.local or have the boot process wait until the client has received a valid IP?

Thanks.
 
Re: mfsBSD interface not obtaining dhcp address on boot

Would adding the line sleep 20 to the beginning of /etc/rc.local have the file wait before executing the next line? to my understanding this might work but I haven't been able to try as of yet
 
Re: mfsBSD interface not obtaining dhcp address on boot

Does mfsBSD use SYNCDHCP? If not, set that:
/etc/rc.conf
Code:
ifconfig_DEFAULT="SYNCDHCP"
 
Re: mfsBSD interface not obtaining dhcp address on boot

wblock@ said:
Does mfsBSD use SYNCDHCP? If not, set that:
/etc/rc.conf
Code:
ifconfig_DEFAULT="SYNCDHCP"

Hmm I added this and still nothing.
I also tried adding synchronous_dhclient="YES" and it still did not work. I think perhaps mfsbsd handles networking differently?

I believe mfsbsd handles networking thru /etc/rc.d/mfsbsd but I don't know what to make of it, pasted below:
Code:
#!/bin/sh
# $Id$

# PROVIDE: mfsbsd
# BEFORE: NETWORKING netif routing hostname
# REQUIRE: mountcritlocal mdinit
# KEYWORD: FreeBSD

. /etc/rc.subr

name="mfsbsd"
start_cmd="mfsbsd_start"
stop_cmd=":"

mfsbsd_start()
{
        _hn=`/bin/kenv -q mfsbsd.hostname`
        _clif=`/bin/kenv -q mfsbsd.cloned_interfaces`
        _mif=`/bin/kenv -q mfsbsd.mac_interfaces`
        _dhcp=`/bin/kenv -q mfsbsd.autodhcp`
        _if=`/bin/kenv -q mfsbsd.interfaces`
        _dr=`/bin/kenv -q mfsbsd.defaultrouter`
        _sr=`/bin/kenv -q mfsbsd.static_routes`
        _ns=`/bin/kenv -q mfsbsd.nameservers`
        _rootpw=`/bin/kenv -q mfsbsd.rootpw`
        _rootpwhash=`/bin/kenv -q mfsbsd.rootpwhash`
        if [ -n "$_hn" ]; then
                echo "hostname=\"$_hn\"" >> /etc/rc.conf.d/hostname
        fi
        if [ -n "$_clif" ]; then
                echo "cloned_interfaces=\"$_clif\"" >> /etc/rc.conf.d/network
        fi
        if [ -n "$_mif" ]; then
                echo "mac_interfaces=\"$_mif\"" >> /etc/rc.conf.d/interfaces
                for i in $_mif; do
                        _mac=`/bin/kenv mfsbsd.ifconfig_${i}_mac`
                        if [ -n "$_mac" ]; then
                                echo "ifconfig_${i}_mac=\"$_mac\"" >> /etc/rc.conf.d/interfaces
                        fi
                        _config=`/bin/kenv mfsbsd.ifconfig_$i`
                        if [ -n "$_config" ]; then
                                echo "ifconfig_$i=\"$_config\"" >> /etc/rc.conf.d/interfaces
                        fi
                done
        fi
        if [ -n "$_dhcp" ]; then
                if `checkyesno _dhcp`; then
                        _dif=`/sbin/ifconfig -l | /usr/bin/sed -E 's/lo[0-9]+//g'`
                        for i in $_dif; do
                                echo "ifconfig_$i=\"DHCP\"" >> /etc/rc.conf.d/network
                        done
                fi
        fi
        for i in $_if $_mif $_clif; do
                _config=`/bin/kenv mfsbsd.ifconfig_$i`
                if [ -n "$_config" ]; then
                        echo "ifconfig_$i=\"$_config\"" >> /etc/rc.conf.d/network
                fi
        done
        if [ -n "$_dr" ]; then
                echo "defaultrouter=\"$_dr\"" >> /etc/rc.conf.d/routing
        fi
        if [ -n "$_sr" ]; then
                echo "static_routes=\"$_sr\"" >> /etc/rc.conf.d/routing
                for i in $_sr; do
  			_config=`/bin/kenv mfsbsd.route_$i`
                        if [ -n "$_config" ]; then
                                echo "route_$i=\"$_config\"" >> /etc/rc.conf.d/routing
                        fi
                done
        fi
        if [ -n "$_rootpw" ]; then
                echo $_rootpw | /usr/sbin/pw usermod root -h 0
                /bin/kenv -u mfsbsd.rootpw
        elif [ -n "$_rootpwhash" ]; then
                echo $_rootpwhash | /usr/bin/sed -e 's,%,$,g' | /usr/sbin/pw usermod root -H 0
                /bin/kenv -u mfsbsd.rootpwhash
        fi
        if [ -n "$_ns" ]; then
                for n in $_ns; do
                        echo "nameserver $n" >> /etc/resolv.conf
                done
        fi
}

load_rc_config $name
run_rc_command "$1"

I think the above file might be overwriting what's inside /etc/rc.conf and that is why none of the aforementioned commands are working.
Can anyone confirm this?

Thanks.
 
Re: mfsBSD interface not obtaining dhcp address on boot

Look at the files in /etc/rc.conf.d/, especially the network one. What's in there?

I wonder at the order the files are read, as the last file read will overwrite variables set in previous files. So, if rc.conf is read first, then the files in rc.conf.d are read, they take precedence.

Perhaps if you add the netwait options to a file named /etc/rc.conf.d/zz-netwait, that will take precedence?
 
Re: mfsBSD interface not obtaining dhcp address on boot

Well, seems I got a fix finally! :)

Turns out that /etc/rc.conf.d/network takes precedence over /etc/rc.conf, and /etc/rc.d/mfsbsd is the file which populates the network file. What I ended up doing was modifying the existing line in /etc/rc.d/mfsbsd which read echo "ifconfig_$i=\"DHCP\"" >> /etc/rc.conf.d/network and changed it to echo "ifconfig_$i=\"[color=#FF0000]SYNCDHCP[/color]\"" >> /etc/rc.conf.d/network. So now when I boot to mfsBSD instead of /etc/rc.conf.d/network containing this line: ifconfig_eth0="DHCP" it now contains: ifconfig_eth0="SYNCDHCP" which now lets the system wait to finish boot until it receives a valid IP.

Thanks for all the help everybody, I can honestly say the FreeBSD forums contain some of the most helpful people I have come across.

Cheers :beergrin
-John
 
Back
Top