Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 96322 - eth0 not getting an ip address from dhclient when starting /etc/init.d/net.eth0
Summary: eth0 not getting an ip address from dhclient when starting /etc/init.d/net.eth0
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: AMD64 Linux
: High normal (vote)
Assignee: Roy Marples (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-16 16:56 UTC by John Koch
Modified: 2005-07-14 03:03 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Koch 2005-06-16 16:56:40 UTC
When using the modular net.eth0 init scripts to get an IP via DHCP problems
occur. The scripts detect that I'm using dhclient and try to use it but after
they run dhclient they fail. The only easily found information is that dhclient
was run properly and an IP address was assigned.

Reproducible: Always
Steps to Reproduce:
1./etc/init.d/net.eth0 start
2.
3.

Actual Results:  
eth0 seems to be brought up and get a valid ip
then it is brought down, dhclient is killed and the init scripts throw [!!]

Expected Results:  
eth0 should be brought up, an ip is assigned via dhcp and the init scripts are
happy [ OK ]

The init scripts actually bring eth0 up properly and get a valid IP address via
the DHCP server. However, the dhclient script is looking for a string to be
output which first of all doesn't happen and second of all wouldn't work. When
the string is not found the scripts assume it didn't work and then kill dhclient
and bring eth0 down. A quick but poor fix was to comment out line 124 in
/lib/rcscripts/net.modules.d/dhclient that read [[ ${x:${#x} -5:5} == bound ]].
This line seemed to be extracting a segment of the dhclient output and comparing
it against bound. First of all, dhclient is in quiet mode so it doesn't output
anything, and secondly, when I took dhclient out of quiet mode by removing the
-q on line 122 the script still didn't work. I am not sure of a good fix but I
thought I should bring this to someones attention.
Comment 1 Roy Marples (RETIRED) gentoo-dev 2005-06-17 01:34:08 UTC
The -q option is to quiet the output of the dhclient binary - the script it
calles echos the action that dhclient sends to the script so we can check if
dhclient actually did get an address

Could you put the following just before line 124, so it reads

echo "${x}"
[[ ${x:${#x} - 5:5} == bound ]]

and post the output of net.eth0 starting - thanks
Comment 2 John Koch 2005-06-17 02:21:47 UTC
(In reply to comment #1)
> The -q option is to quiet the output of the dhclient binary - the script it
> calles echos the action that dhclient sends to the script so we can check if
> dhclient actually did get an address
> 
> Could you put the following just before line 124, so it reads
> 
> echo "${x}"
> [[ ${x:${#x} - 5:5} == bound ]]
> 
> and post the output of net.eth0 starting - thanks

/etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhclient ...
                                                                          [ !! ]

All that seemed to do was print out a blank line. Before adding the echo
statement and not commenting out line 124 it read:


/etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhclient ...                                             [ !! ]
Comment 3 Roy Marples (RETIRED) gentoo-dev 2005-06-17 05:50:49 UTC
It should still say something!

Try changing line 121 from
local x=$( dhclient ${opts} -1 -sf ${script} -pf ${pidfile} -q ${iface} )
to
local x=$( dhclient ${opts} -1 -sf ${script} -pf ${pidfile} -q ${iface} 2>&1 )

That captures errors too and with the echo "${x}" line we should see somthing now
Comment 4 John Koch 2005-06-17 10:40:11 UTC
I change the script like you said, it now looks like:

/lib/rcscripts/net.modules.d/dhclient
121:        eval opts=\"\$\{dhclient_${ifvar}\}\"
122:        local x=$( dhclient ${opts} -1 -sf ${script} -pf ${pidfile} -q
${iface} 2>&1)
123:        # We just check the last 5 letters
124:        echo "${x}"
125:        [[ ${x:${#x} - 5:5} == bound ]]
126:        if [[ $? != 0 ]]; then

But I still get the exact same output upon invoking /etc/init.d/net.eth0 start

/etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhclient ...
                                                                          [ !! ]
Comment 5 John Koch 2005-06-17 10:44:35 UTC
Also, to verify that it just wasn't my Athlon64 computer (I have no idea why it
should be) I tried it on my Athlon T-Bird desktop and my Pentium 3 laptop. All
are doing the exact same thing, and commenting out that one check solves the
problem on each, even though it is more of just ignoring the problem than
solving it.
Comment 6 Roy Marples (RETIRED) gentoo-dev 2005-06-17 11:01:36 UTC
OK - try commenting line 122 so it doesn't get lost and use this

set -x
dhclient ${opts} -1 -sf ${script} -pf ${pidfile} -q ${iface}
return 1

That will still error and stop, but please post the output
Comment 7 John Koch 2005-06-17 11:06:47 UTC
One other thing when I do:
tail -f /var/log/messages

I see:
Jun 17 13:00:03 Halcyon dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Jun 17 13:00:03 Halcyon dhclient: DHCPACK from 192.168.1.1
Jun 17 13:00:03 Halcyon dhclient: bound to 192.168.1.109 -- renewal in 38385
seconds.

Even though the script fails clearly it worked temporarily because I got a valid
lease. But when looking at the dhclient script file again we see:

/lib/rcscripts/net.modules.d/dhclient
123:        # We just check the last 5 letters
124:        echo "${x}"
125:        [[ ${x:${#x} - 5:5} == bound ]]

I don't know exactly how line 125 works, but the comment states that it is
checking the last 5 letters of the output. I realize that
${x:${#x} - 5:5}
is stripping off 5 letters, but is it from the begining or end? And if it is
from the end, assuming it is even doing that or there is even something to
strip, shouldn't it be taking it from the begining as seen by:
Jun 17 13:00:03 Halcyon dhclient: bound to 192.168.1.109 -- renewal in 38385
seconds.

Just a thought, I don't know.
Comment 8 John Koch 2005-06-17 11:14:06 UTC
/lib/rcscripts/net.modules.d/dhclient
121:        eval opts=\"\$\{dhclient_${ifvar}\}\"
122:        #local x=$( dhclient ${opts} -1 -sf ${script} -pf ${pidfile} -q ${iface
123:        set -x
124:        dhclient ${opts} -1 -sf ${script} -pf ${pidfile} -q ${iface}
125:        return 1
126:        # We just check the last 5 letters
127:        echo "${x}"                       
128:        [[ ${x:${#x} - 5:5} == bound ]]
129:        if [[ $? != 0 ]]; then

#/etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhclient ...
+ dhclient -1 -sf /lib/rcscripts/net.modules.d/helpers.d/dhclient-ifconfig -pf
/var/run/dhclient-eth0.pid -q eth0
+ LC_ALL=C
+ /sbin/dhclient -1 -sf /lib/rcscripts/net.modules.d/helpers.d/dhclient-ifconfig
-pf /var/run/dhclient-eth0.pid -q eth0
+ return 1
+ x=1
+ eoutdent
+ local i=
+ ((  i > 0  ))
+ ((  i = RC_DEFAULT_INDENT  ))
+ esetdent 4
+ local i=4
+ ((  i < 0  ))
++ printf %4s ''
+ RC_INDENTATION='    '
+ [[ 1 == 0 ]]
+ [[ -n '' ]]
+ (( config_counter++  ))
+ (( config_counter<1 ))
+ eoutdent
+ local i=
+ ((  i > 0  ))
+ ((  i = RC_DEFAULT_INDENT  ))
+ esetdent 2
+ local i=2
+ ((  i < 0  ))
++ printf %2s ''
+ RC_INDENTATION='  '
+ false
+ return 1
+ interface_down eth0
+ ifconfig_down eth0
+ ifconfig eth0 down
+ eend 1
+ local retval=1
+ shift
+ _eend 1 eerror ''
+ local retval=1 efunc=eerror msg
+ shift 2
+ [[ 1 == 0 ]]
+ [[ -c /dev/null ]]
+ rc_splash stop
+ [[ -n '' ]]
+ msg='[ !! ]'
+ [[ yes == yes ]]                                                        [ !!
]' echo -e '                                                               [ !! ]
+ return 1
+ LAST_E_CMD=eend
+ return 1
+ return 1
+ false
+ return 1
+ return 1

tail -f /var/log/messages
Jun 17 13:13:33 Halcyon dhclient: DHCPREQUEST on eth0 to 255.255.255.255 port 67
Jun 17 13:13:33 Halcyon dhclient: DHCPACK from 192.168.1.1
Jun 17 13:13:33 Halcyon dhclient: bound to 192.168.1.109 -- renewal in 32462
seconds.
Jun 17 13:13:33 Halcyon dhclient: receive_packet failed on eth0: Network is down
Comment 9 Roy Marples (RETIRED) gentoo-dev 2005-06-17 11:58:05 UTC
OK - re emerge baselayout so that we start afresh.

Post the output of the following
ls -l /lib/rcscripts/net.modules.d/helpers.d

Then add this to dhclient-ifconfig in that directory - just before the exec line
touch /tmp/a

Then add this to dhclient-udhcpc-wrapper in that directory - just before the
iface_type line
set > /tmp/b

Then add this to udhcpc-ifconfig in that directory - just before the action=
set > /tmp/c

Finally, attach those 3 files to this bug
Comment 10 John Koch 2005-06-17 13:01:55 UTC
ls -l /lib/rcscripts/net.modules.d/helpers.d/
total 18
-rw-r--r--  1 root root 4441 Jun 17 14:47 config-system
-rwxr-xr-x  1 root root  397 Jun 17 14:47 dhclient-ifconfig
-rwxr-xr-x  1 root root  397 Jun 17 14:47 dhclient-iproute2
-rwxr-xr-x  1 root root 1348 Jun 17 14:47 dhclient-udhcpc-wrapper
-rw-r--r--  1 root root 2408 Jun 17 14:47 functions
-rwxr-xr-x  1 root root 2311 Jun 17 14:47 udhcpc-ifconfig
-rwxr-xr-x  1 root root 2267 Jun 17 14:47 udhcpc-iproute2

---------------------------------------------------------------

cat /lib/rcscripts/net.modules.d/helpers.d/dhclient-ifconfig 
#!/bin/sh
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header:
/var/cvsroot/gentoo-src/rc-scripts/net-scripts/net.modules.d/helpers.d/Attic/dhclient-ifconfig,v
1.10.4.3 2005/05/15 22:47:41 vapier Exp $

# Contributed by Roy Marples (uberlord@gentoo.org)

touch /tmp/a
exec /lib/rcscripts/net.modules.d/helpers.d/dhclient-udhcpc-wrapper ifconfig

---------------------------------------------------------------

cat /lib/rcscripts/net.modules.d/helpers.d/dhclient-udhcpc-wrapper
#!/bin/sh
# Copyright (c) 2004-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-src/rc-scripts/net-scripts/net.modules.d/helpers.
d/Attic/dhclient-udhcpc-wrapper,v 1.4.2.2 2005/01/25 10:42:54 uberlord Exp $

# Contributed by Roy Marples (uberlord@gentoo.org)

# Instead of writing new functions for dhclient, we simply map their variables
# over to udhcpc style ones and call those scripts!

set > /tmp/b
iface_type=${1}

echo ${reason}
case "${reason}" in
        BOUND|REBOOT|REBIND) action=bound ;;
...

---------------------------------------------------------------

cat /lib/rcscripts/net.modules.d/helpers.d/udhcpc-ifconfig
#!/bin/sh
# Copyright (c) 2004-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-src/rc-scripts/net-scripts/net.modules.d/helpers.
d/Attic/udhcpc-ifconfig,v 1.15.2.3 2005/01/25 10:42:54 uberlord Exp $

# Contributed by Roy Marples (uberlord@gentoo.org)

set > /tmp/c
action=${1}
echo ${action}

case "${action}" in
        bound|renew|deconfig)
                # We handle these actions
...

---------------------------------------------------------------

As for /tmp/a /tmp/b and /tmp/c none of them got created...
Comment 11 Roy Marples (RETIRED) gentoo-dev 2005-06-20 14:04:19 UTC
OK - that means that none of the scripts are being run at all!

Let's see if we can find out why. Try removing the -q option and replacing it
with the -d option.

local x=$( dhclient ${opts} -1 -sf ${script} -pf ${pidfile} -d ${iface} 2>&1 )
Comment 12 John Koch 2005-06-20 14:17:55 UTC
All that has seem to do is stall out the init script. eth0 comes up fine, as it
did before, however it stays up now because the init script never seems to get
to the point where it thinks something is wrong and brings it down. If I ctrl-c
eth0 remains up and the init scripts seem to think net.eth0 is started and I can
stop it normally. However it still hangs

/etc/init.d/net.eth0 start
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhclient ...
Comment 13 Roy Marples (RETIRED) gentoo-dev 2005-06-22 00:17:26 UTC
OK - create the file /tmp/dhclient
#!/bin/sh
touch /tmp/dhclient.$$

Then run
chmod +x /tmp/dhclient
dhclient -sf /tmp/dhclient eth0

If that works, some files in /tmp called dhclient.<number> should have been
created. If so then try this
dhclient -sf /lib/rcscripts/net.modules.d/helpers.d/dhclient-ifconfig eth0

And attach the output of both dhclient commands to this bug please.
Comment 14 John Koch 2005-06-22 00:34:43 UTC
Created /tmp/dhclient
#!/bin/sh
touch /tmp/dhclient.$$

Listing to verify rights
ls -l /tmp/dhclient 
-rwxr-xr-x  1 root root 33 Jun 22 02:25 /tmp/dhclient

dhclient -sf /tmp/dhclient eth0
Internet Systems Consortium DHCP Client V3.0.1
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/products/DHCP

Listening on LPF/eth0/00:d0:59:3e:24:ca
Sending on   LPF/eth0/00:d0:59:3e:24:ca
Sending on   Socket/fallback
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.109 -- renewal in 41445 seconds.

No /tmp/dhclient.# files are created
upon ./tmp/dhclient a dhclient.23668 file is created but none upon execution of
the dhclient binary

I doubt therefore this will contain any useful information seeing as -sf doesn't
seem to be doing what is expected, but here is the output anyway.

dhclient -sf /lib/rcscripts/net.modules.d/helpers.d/dhclient-ifconfig eth0
Internet Systems Consortium DHCP Client V3.0.1
Copyright 2004 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/products/DHCP

Listening on LPF/eth0/00:d0:59:3e:24:ca
Sending on   LPF/eth0/00:d0:59:3e:24:ca
Sending on   Socket/fallback
DHCPREQUEST on eth0 to 255.255.255.255 port 67
DHCPACK from 192.168.1.1
bound to 192.168.1.109 -- renewal in 37923 seconds.
Comment 15 Hiel Van Campen 2005-06-22 10:04:00 UTC
I have a question. the script isnt being run right well I was trying to figure
out  how things got to /lib/rcscripts/net.modules.d/dhclient.  SO I tried to
follow this 
# Fix any potential localisation problems
# Note that LC_ALL trumps LC_anything_else according to locale(7)
dhclient() {
        LC_ALL=C /sbin/dhclient "$@"
}

and I dont have this in /sbin, I only have " /sbin/dhcpcd ".
I'm running   sys-apps/baselayout-1.11.12-r4 and so far I have no problems knock
on wood.
Comment 16 Roy Marples (RETIRED) gentoo-dev 2005-06-22 10:32:16 UTC
dhclient is a dhcp client as is dhcpcd - udhcpc and pump are two other dhcp clients.

dhcpcd and pump are self contained and does not require any scripts.
dhclient and udhcpc simply pass the retrieved dhcp values from a server and then
let a script configure the system.

So if dhclient cannot execute any scripts then it's never going to work :/

However, you don't normally need to specify which dhcp client you use as the
system makes a good guess - it chooses dhcpcd by default if there is more than
one installed, otherwise it uses the first one it finds or as specified in the
modules=( ... ) directive.
Comment 17 John Koch 2005-06-24 11:20:35 UTC
Okay, this has been driving me crazy so I started thinking about it again. I
could think of no other reason why dhclient wouldn't be running scripts. I tried
emerging the unstable version and even downgrading the dhclient version. I then
recalled that dhclient must be running a script, just not the one we wanted it
to run. Before the new scripts had been writen I had used dhclient before, but a
friend of mine had set it up for me because I had been using dhcpcd. In doing
this we were using the default script file that came with dhclient. I had a
dhclient.conf file in /etc that had somethings in it and was very similar to the
example in /etc/dhcp/dhclient.conf. There is a line in it that reads :

script "/etc/dhcp/dhclient-script";

I began to recall that without a script dhclient would always get pissed and I
wondered if it was by default always using that script and not accepting the -sf
parameter because of that. I edited the script to have it echo a message to see
if it was being run and indeed it was. When I removed the line from my
dhclient.conf about the script and executed dhclient it complained about not
having a script. When I provided it a script it ran it. I move both
/etc/dhclient.conf and /etc/dhcp into /root and emerge -C dhcp and emerge dhcp.
The /etc/dhclient.conf file was not remade but /etc/dhcp was. Reverting all of
are changes back and executing /etc/init.d/net.eth0 start seems to fix the problem.

/etc/init.d/net.eth0 start 
 * Starting eth0
 *   Bringing up eth0
 *     dhcp
 *       Running dhclient ...                                             [ ok ]
 *       eth0 received address 192.168.1.109

I am not sure why dhclient will not let you force a different script file if one
is defined in its dhclient.conf, or why there was even a dhclient.conf when it
clearly seems to not need it. I supposed without passing it a bunch of command
line args you might need it. If this comes up again I will know where to look
now. If there are any ideas you can suggest to me about dhclient and why it
woudl do this I'm curious.
Comment 18 Matt 2005-06-29 09:28:25 UTC
I had the same problem.  I looked into it and found the problem.  On my updates
last night I got a new version of udhcp (0.9.9_pre20041216).  This version puts
the udhcpc and udhcpd executables in /usr/sbin/ and the networking scripts look
in /sbin.  I created symlinks in /sbin and the problem was solved.  Everything
works great now.
Comment 19 Roy Marples (RETIRED) gentoo-dev 2005-06-29 09:40:56 UTC
(In reply to comment #18)
> I had the same problem.  I looked into it and found the problem.  On my updates
> last night I got a new version of udhcp (0.9.9_pre20041216).  This version puts
> the udhcpc and udhcpd executables in /usr/sbin/ and the networking scripts look
> in /sbin.  I created symlinks in /sbin and the problem was solved.  Everything
> works great now.

That's a completely different problem - but it's already fixed in
udhcp-0.9.9_pre20041216-r1
Comment 20 Roy Marples (RETIRED) gentoo-dev 2005-06-29 09:43:06 UTC
John Kock, thanks for all the trouble shooting

I've put a check into the dhclient net-scripts module that checks for any script
lines and then fails if it finds them.

Will be in baselayout-1.11.13
Comment 21 Roy Marples (RETIRED) gentoo-dev 2005-07-14 03:03:23 UTC
baselayout-1.11.13 is out