Freebsd – Why does dhclient only work if its not specified in /etc/rc.conf

dhcpfreebsd

I have just set up a FreeBSD 8.1 in a VM and am trying to get it to do DHCP automatically. Right now, if I leave /etc/rc.conf like so:

#ifconfig_de0="DHCP"

then I can do dhclient de0 and it gets an IP instantly.

If I remove the comment so that DHCP is supposedly automatic, then dhclient de0 never gets an address (and it doesn't happen automatically either)

I get DHCPREQUEST on de0 to 255.255.255.255 port 67

Nothing else changes, what am I doing wrong?

I've also tried using sysinstall, but I have found no way to get it to write the changes to the files once I make them…..

==== Edit

Hoping to save someone else the time I spent on this, here is my rc.conf:

# -- sysinstall generated deltas -- # Mon Dec  6 11:51:13 2010
# -- sysinstall generated deltas -- # Wed Dec  8 08:28:27 2010
# Created: Mon Dec  6 11:51:13 2010
# Enable network daemons for user convenience.
# Please make all changes to this file, not to /etc/defaults/rc.conf.
# This file now contains just the overrides from /etc/defaults/rc.conf.
#REMOVED: inetd_enable="YES"
hostname="pfsensedev.intomec.com"
#ifconfig_de0="DHCP"
inetd_enable="NO"
sshd_enable="YES"

I found that I had to comment out the ifconfig_de0 line if I wanted to get an IP address assigned. If I left it in rc.conf, it was impossible to get an IP address via dhclient.

Putting the lines into /etc/rc.local did the trick

dhclient de0

I'm running this on a MS Virtual PC VM under Win7x64 (already had it loaded for XP Mode).

Thanks for the help guys.

Best Answer

You are doing it right. If it doesn't work in your case, you could also use /etc/rc.local. Put the command dhclient de0 into this file and it will be run upon system start.