DHCP client on removable interface

Alexander Pohoyda alexander.pohoyda at gmx.net
Sun Aug 3 11:31:37 PDT 2003


Hi all,

I was having problems with dhclient program on my notebook.

The symptom:
Every time I turned the notebook ON with a PCMCIA NIC inserted, no
DHCP configuration was present on the ed0 interface. DHCP worked well
anytime I inserted a NIC after the system startup.

The configuration:
/etc/rc.conf
ifconfig_ed0="dhcp"

/etc/defaults/rc.conf
network_interfaces="auto"

The system:
FreeBSD oak.pohoyda.family 4.8-STABLE FreeBSD 4.8-STABLE #68: Mon Jul 21 20:31:53 CEST 2003     apog at oak.pohoyda.family:/usr/src/sys/compile/OAK  i386


I investigated the issue and found out that the dhclient program is
called twice during the system startup when a NIC is inserted.
First, it is called from the /etc/pccard_ether, and this time
interface is successfully configured.
Second time it is called from the /etc/rc.network, and after this
call the interface is left disconfigured.

If I insert the card after system startup, dhclient is called only
once, and everything works as expected.

Am I doing something wrong? Has anybody experienced this as well?
What's the correct way to fix this?

My solution goes like this:
======
--- rc.network.orig     Sun Aug  3 20:23:32 2003
+++ rc.network  Tue Jun 24 09:46:30 2003
@@ -218,7 +218,10 @@
        done
 
        if [ ! -z "${dhcp_interfaces}" ]; then
-               ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
+               ps -ax | grep dhclient >/dev/null
+               if [ $? = 1 ]; then
+                       ${dhcp_program:-/sbin/dhclient} ${dhcp_flags} ${dhcp_interfaces}
+               fi
        fi
 
        for ifn in ${network_interfaces}; do
======

It works great for me.


-- 
Alexander Pohoyda
<alexander.pohoyda at gmx.net>


More information about the freebsd-mobile mailing list