# initiating dhcp on boot problem....

## hollywoodb

on gentoo startup, the nvnet module loads fine, but then there's a warning that the system was unable to bring up eth0, and later something about netstart or netmount.  Anyways, once I've logged in if I "dhcpcd eth0" everything works fine after that.  I have "nvnet" in my /etc/modules.autoload.d/kernel-2.4 file.  How do I bring up eth0 automatically at boot without errors or the need to type dhcpcd eth0 once logged in?

----------

## ckdake

edit the file /etc/conf.d/net to your liking,  then make sure that /etc/init.d/net.eth0 exists.  if it doesnt, copy /etc/init.d/net to /etc/init.d/net.eth0.  then do 

```
rc-update add net.eth0 default
```

 as root.

----------

## hollywoodb

I've done all that, nvnet initiates fine on startup, then I get this:

* Bringing eth0 up

* eth0 is not plugged in or has no carrier signal

* ERROR: problem starting needed services

* "netmount" was not started

once the system has finished booting and I login, I su and type 'dhcpcd eth0' and everything is peachy after that. but I shouldn't have to take the extra step to dhcpcd

----------

## ckdake

loose cable or bad hub/switch/router/card problem?

----------

## hulk2nd

what happens if you do a /etc/init.d/net.eth start instead of dhcpcd eth0?

----------

## hollywoodb

/etc/init.d/net.eth start

bash: /etc/init.d/net.eth: No such file or directory

/etc/init.d/net.eth0 start

 * Bringing eth0 up...                                                    [ ok ]

so "dhcpcd eth0" and "/etc/init.d/net.eth0 start" work.

"/etc/init.d/net.eth start" doesn't work

----------

## ckdake

what is in your /etc/conf.d/net ?

----------

## hollywoodb

everything is commented except this line:

iface_eth0="dhcp"

----------

## ckdake

that should be right. hmm.

----------

## hollywoodb

OK, i noticed on a fresh reboot that "/etc/init.d/net.eth0 start" gives me the same error i posted above. only dhcpcd eth0 works after a reboot.  once I've started and killed dhcpcd i can do the net.eth0 start.

----------

## mope

I am having the same problem. I have everything commented except iface_eth0="dhcp", too.

I emerged the newest portage (using ACCEPT_KEYWORDS="~x86") because I read in another thread (in PPC) that the problem had been fixed. Evidently other people have been having the same problem, as well. But the new emerge did not fix the problem.

----------

## hollywoodb

is there a way to edit the startup scripts (net.eth0 or netmount) so that all it does is "dhcpcd eth0" ?  I really don't need the full functionality of the script, since it isn't doing anything anyways other than give me an error messages, and all i need it to do is "dhcpcd eth0" to get my ethernet working.

----------

## fjf3

I had the same problem. What card are you using? My problem was that the the net0 script where it goes to figure out if the interface is up, when getting the response from ifconfig it did not awk a RUNNING in there, so it skips over the dhcpcd and goes to the error you see. I did a quick and dirty fix on the eth0 script and it doesn't try to find RUNNING anymore. I think the problem is not the script but probably the card driver confusing ifconfig.

----------

## fjf3

Ohh one more thing. This was woring fine with r2. It stopped working when I emerge r8   :Crying or Very sad: 

----------

## hollywoodb

I'm using an the nforce2 onboard ethernet, forcedeth driver compiled into 2.6 kernel... however its been doing this since I installed gentoo using the 2.4.22 gentoo test sources

----------

## fjf3

Try going editing net.eth0 and find the line where it ask != "RUNNING" and delete the !. That would do it. You may want to copy net.eth0 to something like net.eth0.orig so you know what you changed.

----------

## hollywoodb

i cannot find the specific line you wanted me to edit, here's my net.eth0:

#!/sbin/runscript

# Copyright 1999-2003 Gentoo Technologies, Inc.

# Distributed under the terms of the GNU General Public License v2

# $Header: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.32 2003/11/11 19:37:24 azarah Exp $

#NB: Config is in /etc/conf.d/net

# For pcmcia users. note that pcmcia must be added to the same

# runlevel as the net.* script that needs it.

depend() {

	use hotplug pcmcia

}

checkconfig() {

	if [ -z "${iface_IFACE}" ]

	then

		eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set"

		return 1

	fi

	if [ -n "${vlans}" -a \! -x /sbin/vconfig ]

	then

		eerror "For VLAN (802.1q) support, emerge net-misc/vconfig"

		return 1

	fi

}

setup_env() {

	# No reason to check these multiple times in the file

	iface="${1/\./_}"

	iface_IFACE="$(eval echo \$\{iface_${iface}\})"

	dhcpcd_IFACE="$(eval echo \$\{dhcpcd_${iface}\})"

	inet6_IFACE="$(eval echo \$\{inet6_${iface}\})"

	alias_IFACE="$(eval echo \$\{alias_${iface}\})"

	status_IFACE="$(ifconfig | gawk -v IFACE="${iface}" '/Link/ { if ($1 == IFACE) print "up" }')"

	carrier_IFACE="$(ifconfig | gawk -v IFACE="${iface}" '/RUNNING/ { if ($1 == IFACE) print "running" }')"

	vlans="$(eval echo \$\{iface_${IFACE}_vlans\})"

}

iface_start() {

	local retval=0

	setup_env ${1}

	checkconfig || return 1

	local IFACE="${1}"

	ebegin "Bringing ${IFACE} up"

	if [ "${iface_IFACE}" != "dhcp" ]

	then

		/sbin/ifconfig ${IFACE} ${iface_IFACE} >/dev/null || {

			retval=$?

			eend ${retval} "Failed to bring ${IFACE} up"

			return ${retval}

		}

		# ifconfig do not always return failure ..

		/sbin/ifconfig ${IFACE} &> /dev/null || {

			retval=$?

			eend ${retval} "Failed to bring ${IFACE} up"

			return ${retval}

		}

	else

		# Check that eth0 was not brough up by the kernel ...

		if [ "${status_IFACE}" != "up" ]

		then

			# Check that the interface has a carrier

			if [ "${carrier_IFACE}" = "running" ]

			then

				/sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE} >/dev/null || {

					retval=$?

					eend ${retval} "Failed to bring ${IFACE} up"

					return ${retval}

				}

			else

				eend 1 "${IFACE} is not plugged in or has no carrier signal"

				return 1

			fi

		fi

	fi

	eend 0

	if [ -n "${alias_IFACE}" ]

	then

		local x=""

		local num=0

		local aliasbcast=""

		local aliasnmask=""

		ebegin "  Adding aliases"

		for x in ${alias_IFACE}

		do

			aliasbcast="$(eval echo \$\{broadcast_${iface}\} \| awk \'\{ print \$$((num + 1)) \}\')"

			if [ -n "${aliasbcast}" ]

			then

				aliasbcast="broadcast ${aliasbcast}"

			fi

			aliasnmask="$(eval echo \$\{netmask_${iface}\} \| awk \'\{ print \$$((num + 1)) \}\')"

			if [ -n "${aliasnmask}" ]

			then

				aliasnmask="netmask ${aliasnmask}"

			fi

			ebegin "    ${IFACE}:${num}"

			/sbin/ifconfig ${IFACE}:${num} ${x} \

				${aliasbcast} ${aliasnmask} >/dev/null

			num=$((num + 1))

			eend 0

		done

		save_options "alias" "${alias_IFACE}"

	fi

	if [ -n "${inet6_IFACE}" ]

	then

		local x=""

		ebegin "  Adding inet6 addresses"

		for x in ${inet6_IFACE}

		do

			ebegin "    ${IFACE} inet6 add ${x}"

			/sbin/ifconfig ${IFACE} inet6 add ${x} >/dev/null

			eend 0

		done

		save_options "inet6" "${inet6_IFACE}"

	fi

	if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]

	then

		ebegin "  Setting default gateway"

		# First delete any existing routes if it was setup by kernel ..

		/sbin/route del default dev ${gateway%/*} &>/dev/null

		/sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \

			netmask 0.0.0.0 metric 1 >/dev/null || {

			local error=$?

			ifconfig ${IFACE} down &>/dev/null

			eend ${error} "Failed to bring ${IFACE} up"

			stop

			return ${error}

		}

		eend 0

	fi

	# Enabling rp_filter causes wacky packets to be auto-dropped by

	# the kernel.  Note that we only do this if it is not set via

	# /etc/sysctl.conf ...

	if [ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter ] && \

	   [ -z "$(egrep '^[^#]*rp_filter' /etc/sysctl.conf 2>/dev/null)" ]

	then

		echo 1 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter

	fi

}

iface_stop() {

	local myalias="$(get_options alias)"

	local myinet6="$(get_options inet6)"

	setup_env ${1}

	local IFACE="${1}"

	ebegin "Bringing ${IFACE} down"

	# Also down the inet6 interfaces

	if [ -n "${myinet6}" ]

	then

		local x=""

		for x in ${myinet6}

		do

			/sbin/ifconfig ${IFACE} inet6 del ${x} >/dev/null

		done

	fi

	# Do some cleanup in case the amount of aliases change

	if [ -n "${myalias}" ]

	then

		local x=""

		local num=0

		for x in ${myalias}

		do

			/sbin/ifconfig ${IFACE}:${num} down >/dev/null

			num=$((num + 1))

		done

	fi

	if [ "${iface_IFACE}" = "dhcp" ]

	then

		local count=0

		while /sbin/dhcpcd -z ${IFACE} &>/dev/null && [ "${count}" -lt 9 ]

		do

			# Give dhcpcd time to properly shutdown

			sleep 1

			count=$((count + 1))

		done

		if [ "${count}" -ge 9 ]

		then

			eerror "Timed out trying to stop dhcpcd"

		fi

	else

		/sbin/ifconfig ${IFACE} down >/dev/null

	fi

	eend 0

}

start() {

	iface_start ${IFACE} || return 1

	for vlan in ${vlans}

	do

		/sbin/vconfig add ${IFACE} ${vlan} >/dev/null

		iface_start ${IFACE}.${vlan}

	done

}

stop () {

	setup_env ${IFACE}

	checkconfig || return 1

	for vlan in ${vlans}

	do

		iface_stop ${IFACE}.${vlan}

		/sbin/vconfig rem ${IFACE}.${vlan} >/dev/null

	done

	iface_stop ${IFACE}

}

# vim:ts=4

----------

## fjf3

```
 if [ "${carrier_IFACE}" = "running" ] 
```

to

```

 if [ "${carrier_IFACE}" != "running" ] 
```

should make dhcpcd run. However, if things get fixed down the line then this will break things and you'll have to remove the !

----------

## larkie

I am having the same problem - I can start internet access with dhcpcd eth0. 

 After reading your discussions I was looking at all the net.eth0 files.  I found that /etc/conf.d/net.eth0 is the same file as /etc/conf.d/net.  The  net.eth0 file is also in etc/int.d; etc/runlevels/default, var/lib/init.d/softscripts.  The line referring to "running" does not seem to be in my net.eth0 script.  

What I'm wondering is if the /etc/conf.d/net.eth0 should be the same as the others, and maybe I've somehow saved/copied the /net file to net.eth0???

----------

## irf2003

this may be of interest:

https://bugs.gentoo.org/show_bug.cgi?id=33272

if you are still having problem grab the net.eth0 from

rc-scripts-1.4.3.11p2.tar.bz2, it should be in /usr/portage/distfiles/ if you had an previous baselayout emerged, otherwise download from one of the gentoo mirrors.

1) extract this file /init.d/net.eth0 from rc-scripts-1.4.3.11p2.tar.bz2 

 2) backup /etc/init.d/net.eth0 

 3) copy the extracted net.eth0 to /etc/init.d/net.eth0 

 4) reboot 

 HTH

----------

## jlowell

People are still posting with this problem on a regular basis more than a month after it made it's first appearance. Some have had systems taken out because of it. I encountered it last night after installation on a new webserver I'm setting up here. Now I'm concerned about updating the three workstations on which I've installed Gentoo. I mean there are fixes and there are solutions. This problem would seem important enough to justify a solution and quickly I would think. 

jlowell

----------

