# dhcp won't work, part 40593

## SolarBear

Hi ! I know my problem is a very common one, but I did my homework and Searched. Nothing. A lot of threads on the matter, but a lot never replied with their solution. Shucks.

Context : after my PC boots, I need to use dhcpcd manually.

My kernel is correctly configured and the correct driver (8139too) is loaded. My /etc/conf.d/net is simply

```
iface_eth0="dhcp"
```

Help ?

----------

## Master Shake

Let me get this right.  Your problem is that you have to manually start dhcp instead of it automatically doing so?  If that is the case this will work:

```
rc-update add net.eth0 default

rc-update add dhcpcd default
```

----------

## SolarBear

net.eth0 is already rc-updated as default ; as for dhcpcd, I get a "dhcpcd not found" error.

----------

## mcspiff

so how do you bring up dhcpd when you do it manually?

----------

## SolarBear

 *mcspiff wrote:*   

> so how do you bring up dhcpd when you do it manually?

 

Type "dhcpcd" as root in a console.

----------

## Master Shake

Very strange with the cannot find dhcpcd.  Try emerging it again....either that or start dhcp at default runlevel.

----------

## SolarBear

 *Master Shake wrote:*   

> Very strange with the cannot find dhcpcd.  Try emerging it again....either that or start dhcp at default runlevel.

 

Thanks for the help.

I re-emerged dhcpcd. No beef. Also, trying to add dhcpcd to default runlevel won't work:

```
* /sbin/rc-update: /etc/init.d/dhcpcd not found; aborting.
```

----------

## Master Shake

how about rc-update add /sbin/dhcpcd default

----------

## SolarBear

Hmm...

```
rc-update add /sbin/dhcpcd default

 * /sbin/rc-update: /etc/init.d//sbin/dhcpcd not found; aborting.

```

Good idea,though.

----------

## m@o

do you want to use your box as dhcp server or simply get an ip?

in my case the router is the server and i'm the client.

my linux box only has net.eth0 in the default runlevel.

and i don't have any script called dhcpd in /etc/init.d/

hth

----------

## SolarBear

 *m@o wrote:*   

> do you want to use your box as dhcp server or simply get an ip?
> 
> in my case the router is the server and i'm the client.
> 
> my linux box only has net.eth0 in the default runlevel.
> ...

 

Yes, I'm behind a router too and I'm using dhpc just to get an IP, and net.eth0 is already in the default runlevel. Otherwise, the problem would have been solved a long time ago  :Very Happy: 

----------

## m@o

well then the only thing i could think of is to check the net.eth0 script.

the important part is, as far as i can see:

```

iface_start() {

[...]

if [[ ${ifconfig_IFACE} != dhcp ]]; then

[...]

else

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

                if [[ ${status_IFACE} == up ]]; then

                        einfo "Keeping kernel configuration for ${IFACE}"

                else

                        ebegin "Bringing ${IFACE} up via DHCP"

                        /sbin/dhcpcd -t 10 ${dhcpcd_IFACE} ${IFACE}

                        retval=$?

                        eend $retval

                        if [[ $retval == 0 ]]; then

                                # DHCP succeeded, show address retrieved

[...]
```

the -t 10 option is a little addon i did. this is useful if you use dhcp for a laptop, when you are not connectet to a network then it will not try to get an ip for a minute or more.

it will just try 10 secs.

and if the 

```

iface_eth0="dhcp"
```

option in /etc/conf.d/net is set correctly, the script should run dhcp for you.

hth

m@o

----------

## CAG-Spitfire

Just wanted to ring in and say thank you mao for your suggestion to check the net.eth0 script.  I don't know if it's the exact same problem that SolarBear had, but for the past two days, I would get a message during boot that simply said "Bringing eth0 up" and then do nothing.  I couldn't use a static ip nor dhcp during bootup and would have to manually do a dhcpcd eth0.  It's really been giving me grief the past couple of days.  Well after your suggestion I disovered that my net.eth0 script looks like 

```
start() {

   ebegin "Bringing ${IFACE} up"

   /sbin/ifconfig lo 127.0.0.1 up 2>/dev/null

   /sbin/route add -net 127.0.0.0 netmask 255.0.0.0 \

      gw 127.0.0.1 dev lo 2> /dev/null

   eend 0

}

stop() {

   ebegin "Bringing ${IFACE} down"

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

   eend 0

}
```

What the hell?!  This is on a brand new install using the stage 1/3 method and I have in no way touched that file previously and have only used dispatch-conf to update my scripts!  So something really laid the hurt on my poor little machine.  A little worrisome to say the least, but well at least I learned a couple things (like a few new combinations of swear words).  So I was able to grab the net.eth0 scripts from another machine to solve my problem.  Anyway, a big THANK YOU goes out to you.  You're probably my favorite person on the planet at the moment. :Razz: 

----------

