When I stop net.eth0, the interface is still up with an IP, according to ifconfig. I have eth0 using DHCP and it acquires an infinite lease from the DHCP server, which is the root of the problem. On startup, dhcpcd queries the server and gets the infinite lease. When dhcpcd sees that it is infinite, it reports that and exits immediatly (presumably because an infinite lease never needs to be renewed.) Now when I try to "net.eth0 stop", the script tries to send a signal to the non-running dhcpcd and thinks that it succeeds. However the interface is still up. Reproducible: Always Steps to Reproduce: 1. Acquire an infinite DHCP lease on an interface (eth0, for example) 2. /etc/init.d/net.eth0 stop 3. ifconfig eth0 Actual Results: eth0 Protokoll:Ethernet Hardware Adresse 00:50:2C:03:1C:52 inet Adresse:192.168.1.2 Bcast:192.168.1.255 Maske:255.255.255.0 UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1 ... Expected Results: eth0 Protokoll:Ethernet Hardware Adresse 00:50:2C:03:1C:52 inet Adresse:192.168.1.2 Bcast:192.168.1.255 Maske:255.255.255.0 BROADCAST NOTRAILERS MULTICAST MTU:1500 Metric:1 ... Portage 2.0.47-r10 (default-x86-1.4, gcc-3.2.2, glibc-2.3.1-r4) ================================================================= System uname: 2.4.20 i686 AMD Athlon(tm) XP 2000+ GENTOO_MIRRORS="http://gentoo.oregonstate.edu/ http://www.ibiblio.org/gentoo/" CONFIG_PROTECT="/etc /var/qmail/control /usr/share/config /usr/kde/2/share/config /usr/kde/3/share/config /usr/X11R6/lib/X11/xkb:/usr/kde/3.1/share/config:/usr/share/config" CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d" PORTDIR="/usr/portage" DISTDIR="/usr/portage/distfiles" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/work" PORTDIR_OVERLAY="/usr/local/portage" USE="x86 oss 3dnow apm avi crypt cups encode gif jpeg kde gnome libg++ mikmod mmx mpeg ncurses nls pdflib png quicktime spell truetype xml2 xmms xv zlib alsa gdbm berkdb slang readline arts tetex aalib java X sdl gpm tcpd pam libwww ssl perl python imlib oggvorbis gtk qt motif opengl cdr mbox -svga -esd" COMPILER="gcc3" CHOST="i686-pc-linux-gnu" CFLAGS="-mcpu=athlon -O3 -pipe" CXXFLAGS="-mcpu=athlon -O3 -pipe" ACCEPT_KEYWORDS="x86" MAKEOPTS="-j2" AUTOCLEAN="yes" SYNC="rsync://rsync.gentoo.org/gentoo-portage" FEATURES="sandbox ccache"
Wout, comments please ? I do not know dhcpcd.
Yup, that is correct. dhcpcd does do that, and that is indeed why the interface stays up. So the dhcpcd component needs to get a check to see if the interface is still up after running dhcpcd -k, and bring it down manually if it is. Something like ifconfig $INTERFACE | grep -q UP && ifconfig $INTERFACE down or maybe just ifconfig $INTERFACE down :)
Created attachment 15471 [details, diff] Patch to force interface down
Actually, it's simpler than this. I had this problem, and was able to isolate the problem (at least in my case), to this. The stop() function of the net.eth1 script has a ladder of if statements, choosing the appropriate way to shut down. In the case of DHCP, it does this by calling dhcpcd -k. However, if, when the interface came up it got an "infinite lease" (don't ask me, I've never heard of an infinite lease either. But I put a ton of `set -x`s in, and that's what I found my firewall just gave me. dhcpcd's message on receipt of an "infinite lease" was to shutdown (which makes sense, I suppose). That's fine, but with no dhcp process running (I *had* been wondering about that) using dhcpcd -k doesn't do anything ... and among other things that don't get done, the interface doesn't get dropped. Proposed patch to fix the situation attached. It's pretty simple. Right now if the interface *isn't* dhcp, then it runs ifconfig down. So, just run it anyway. Cover's both situations. Note that this is not related to bug 9529 (which is suggesting that dhcpcd -k is a bad way to drop the interface; I agree) or bug 15579. Cheers, AfC http://www.operationaldynamics.com/about/andrew/
If you do force the shutdowning of the interface, I would like to point out that this is not a good idea for systems that have an nfs mounted root. I think that there should be some way to prevent ifconfig down from being run in that case. Note that in such a case you would be running dhcpcd with the -T option, so that dhcpcd would keep the dhcp-provided address alive, but would not change the ip address (nfs root would be down the same instant). So either an <iface>_NFSROOT parameter would enforce this behaviour, or a generic <iface>_NEVERDOWN would prevent the interface from being brought down or something along those lines...
I have a problem related to this, maybe it's already mentioned. But if I have a static IP and I change it to dynamic it doesn't work just restarted net.eth0. I have to run dhcpd eth0 manually afterwards.
Anders, this is because the interface was still up probably. When the interface is up, dhcpcd will not get started. I don't like that behaviour, but it's a different bug. See bug #28362.
This is fixed in the current baselayouts (for example baselayout-1.9.4-r2) # Stop DHCP (should be N/A for aliases) # Don't trust current configuration... investigate ourselves if /sbin/dhcpcd -z ${i} &>${devnull}; then ebegin " Releasing DHCP lease for ${IFACE}" for ((count = 0; count < 9; count = count + 1)); do /sbin/dhcpcd -z ${i} &>${devnull} || break sleep 1 done [[ ${count} -lt 9 ]] eend $? "Timed out" fi ebegin " Stopping ${i}" ifconfig ${i} down &>${devnull} eend 0