# DHCP at boot time (SOLVED)

## germanobax

Hello folks!

As a good newbie, I'm with a cruel doubt. Any help is welcome.

How do I do to bring my network up (with DHCP) when the system is booting? I already issued the command rc-update add net.eth0 default. but nothing happened. 

My /etc/conf.d/net file has this single line:

iface_eth0="dhcp"

According to the gentoo handbook, my network should be working after reboot, but it isn't. I always need to login as superuser and issue the dhcpcd command to bring my network up. That's the only way I found, but it is very cumbersome.

So, what do I need to do to make my system boot and enable my network automatically?

Thanks in advance.

----------

## Syque

Perhaps you have the correct line in the file, but you should have

iface_eth0="dhcp"

(you're missing an "i").

----------

## codergeek42

It's "iface_eth0" not "face_eth0".  :Wink: 

----------

## germanobax

Oh, sorry... I missed the "i" letter here  :Embarassed:  ...  but in my /etc/conf.d/ file I doesn't...  :Rolling Eyes: 

Well, I already edited my post, sorry.

But let's get back to the problem... any hint of what is going on?

----------

## germanobax

Is there another way to bring my network up while booting?

----------

## praison

Have you added dhcpcd to the startup? Do a rc-update add dhcpcd default

----------

## germanobax

How can I do that? In /etc/init.d/ there's no dhcpcd script, so I can't use rc-update.

I'm trying to create one... but I've neve done such thing.

----------

## praison

Why are you looking in /etc/conf.d/ ? The script will be in /etc/init.d/

----------

## germanobax

Damn, I took 2 hours to edit my last post... the server seems to be at its knees.

----------

## Taladar

You might be missing the appropriate driver for your network card. You have to compile that either in the kernel or as a module.

Please post the output of the commands "lspci -vvv" and "lsmod" so we can see which card you have. (lspci is in the pciutils package)

----------

## praison

 *Taladar wrote:*   

> You might be missing the appropriate driver for your network card. You have to compile that either in the kernel or as a module.
> 
> Please post the output of the commands "lspci -vvv" and "lsmod" so we can see which card you have. (lspci is in the pciutils package)

 

That won't be the problem as he can manually start the network connection. If it was driver related, he wouldn't be able to start the network manually either.

If you definately haven't got the /etc/init.d script, try re-emerging dhcpcd

----------

## germanobax

I reemerged dhcpcd, and it doesn't appear in /etc/init.d/

I've tried to edit /etc/conf.d/local.start, so I wrote:

/etc/init.d/net.eth0 start

When my system booted, I1ve got a message saying that eth0 is already up and working... but my network wasn't working. (then I issued "su, then dhcpcd" and my network started)

So, I edited the file again, but replaced the aforementioned line with:

/sbin/dhcpcd eth0

When my system booted, I've got the error message:

failed to start local

then I issued su, then dhcpcd and my network started... :Exclamation: 

It's amazing. And thanks for the attention.

----------

## germanobax

Praison, could you post your /etc/init.d/dhcpcd script here? So I can try to put it in my /etc/init.d/ directory.

Thanks.

----------

## Taladar

Missed the line about the manual start  :Embarassed: 

I probably shouldn't post during lectures at the University.

There is no /etc/init.d/dhcpcd script on my system either although dhcp works perfectly.

In /etc/conf.d/net.example all options are enclosed in parentheses after the =

The option is called config instead of iface too in that file too. And if you don't configure an interface at all it should default to dhcp (provided you have a net.eth0 added with rc-update).

I believe you can use this if you want to explicitly state to use dhcp but it should work if you don't mention the interface at all in the /etc/conf.d/net:

```

config_eth0=("dhcp")

```

----------

## robdd

Hi there germanobax - I've just changed my /etc/conf.d to use dhcp, and my setup works fine. I DON'T have a dhcpd script entry in /etc/init.d, so I don't think that is the problem.

First of all can you please check to see whether you have a directory /etc/dhcpc ?  If so what files are in there ? If the directory is there then you probably have the dhcpcd daemon installed OK.  As far as I can see the dhcpcd daemon is started by the net.eth0 script, so I'm guessing your problem is that you don't have net.eth0 executed at startup - or maybe there's another configuration problem ?

To check when your net.eth0 script is supposed to run type "rc-update -s", and search for the line net.eth0 - if it's followed by default then that's good, otherwise you need to type 'rc-update add net.eth0 default'.

Next, enable debugging by having the following lines in /etc/conf.d/net:

...

iface_eth0="dhcp"

dhcpcd_eth0="-d"

...

The '-d' flag will make dhcpcd log debug messages to /var/log/messages - look at the end of that file after rebooting, and see if the dhcp daemon is running.

Post the results of trying the above, and we'll see if we can find what's going wrong.

Good luck  :Smile: 

----------

## germanobax

Taladar:

I've tried to change my /etc/conf.d/net file and typed down the line

config_eth0=("dhcp") 

and it didn't solve the problem.

Robdd:

I don't have a /etc/dhcpc. Instead, I have a /etc/dhcp, that has the files: 

```
dhclient-script.sample 

dhclient.conf.sample 

dhcpd.conf.sample
```

I've reemerged dhcpcd. As it didn't solved my problem, I emerged dhcp, but it doesn't solve either (of course... dhcp is to enable a server, as I found out). Maybe my /etc/dhcp/ directory is for the latter.

net.eth0 is in my startup list (if you have a better way to name it, please tell), as I issued rc-update -s and it showed net.eth0 |     default

My /var/log/messages file, after the alterations you proposed,  has:

```
...blah, blah, blah...

gdm-autologin(pam_unix)[9468]: session opened for user germano by (uid=0)

dhcpcd[6694]: timed out waiting for DHCP_ACK response

dhcpcd[6694]: broadcasting DHCP_DISCOVER

su(pam_unix)[9606]: timed out waiting for a valid DHCP server response

eth0: Media Link on 100mbps full-duplex

NET: Registered protocol family 10

...I think the rest is trash...

```

I tried to add the line dhcpcd_eth0="-t 120" to /etc/conf.d/net to extend the time needed expect a DHCP server response... and it didn't solve the problem.

Well, my next try will be to use medidation to activate my chakras, then use the power of mind... 

Thanks for the ongoing help guys. I expect that you don't get white hair because of that problem, as I'm almost doing - that's the price to pay to be a newbie.

----------

## germanobax

Look at that:

After I start Fluxbox, I open a Eterm instance, type su, issue dhcpcd, exit, and everything works.

Now, I made the same thing, but instead of issue dhcpcd, I issued /etc/init.d/net.eth0 restart... and everything worked as well.

Well, then the only thing I could still think to try was to edit /etc/conf.d/local.start. First, I just entered a line with:

dhcpcd

Now, when booting the system, the last thing that appears is a starting local message. Then after around 2 minutes waiting to local "start", it says: failed. Beautiful.

Ok, as a good German descendant (in Brazil), I don't give up until I draw milk of a stone.

I removed the dhcpcd command of local.start, and replaced by:

/etc/init.d/net.eth0 restart

Again, booting the system... and I got the message:

```
failed to start local [!!]

ERROR: problem starting needed services

"netmount" was not started
```

Excellent. But rc-update show shows me: netmount | default...

And nothing more happens after local is started (or tried)... X is started with my default user. Then to start my network, I need to just open Eterm, su, dhcpcd, exit... and my network is up and running.

What is going on? I think I wasn't a good boy last year...

----------

## germanobax

Does anybody have a clue?

----------

## jdgill0

 *germanobax wrote:*   

> ... 
> 
> ```
> ...blah, blah, blah...
> 
> ...

 

I think this is at the root of your problem.  By the way there is no /etc/init.d/dhcpcd.  I have no such file myself and my net.eth0 works just fine.

Did you add your nic card in the kernel as a module?  If so, did you add it to /etc/modules.autoload.d? If not, could be your nic is not initialized during boot earlier enough for dhcpcd to be able to use it.

----------

## Mo6eB

look at the manpage for dhcpcd. you may have to start it with some flags. for instance my /etc/conf.d/net looks like this:

```
iface_eth0="dhcp"

dhcpcd_eth0="-H -D -N -t 10"

```

 *Quote:*   

> -H Forces dhcpcd to set hostname of the host to the hostname option supplied by DHCP server. By default dhcpcd will NOT set hostname of the host to the hostname option received from DHCP server.

 

 *Quote:*   

> -D Forces dhcpcd to set domainname of the host to the domainname option supplied by DHCP server.

 

 *Quote:*   

> -t Specifies (in seconds ) for how long dhcpcd will try to get an IP address. The default is 60 seconds. dhcpcd will not fork into background until it gets a valid IP address in which case dhcpcd will return 0 to the parent process. In a case dhcpcd times out before receiving a valid IP address from DHCP server dhcpcd will return exit code 1 to the parent process.

 

All of this is just copy-pasted from dhcpcd's manpage. Oh, and there is no dhcpcd script in /etc/init.d/

----------

## lousyd

 *jdgill0 wrote:*   

> Did you add your nic card in the kernel as a module?  If so, did you add it to /etc/modules.autoload.d? If not, could be your nic is not initialized during boot earlier enough for dhcpcd to be able to use it.

 

That's probably it.  After starting the connection manually, do a "lsmod" and figure out which one of those modules belongs to your network card.  (You may already know.)  Then edit /etc/modules.autoload.d/kernel-2.6 (or kernel-2.4, if that's what you're using) and add the name of your network card's module in there.

This loads the module in time for the card to be used by dhcpcd.  I had this same problem a while back.

----------

## germanobax

 *jdgill0 wrote:*   

> 
> 
> Did you add your nic card in the kernel as a module?  If so, did you add it to /etc/modules.autoload.d? If not, could be your nic is not initialized during boot earlier enough for dhcpcd to be able to use it.

 

 *lousyd wrote:*   

> 
> 
> That's probably it. After starting the connection manually, do a "lsmod" and figure out which one of those modules belongs to your network card. (You may already know.) Then edit /etc/modules.autoload.d/kernel-2.6 (or kernel-2.4, if that's what you're using) and add the name of your network card's module in there.
> 
> This loads the module in time for the card to be used by dhcpcd. I had this same problem a while back.

 

Guys, THANKS for the help!!! It finally works!!! 

I lost 1 gallon of sweat - the price to pay for being a newbie - but finally I could make that thing work. Thanks A LOT!!! If one day I become millionaire, I'll give my ten percent to you.

----------

## lousyd

 *germanobax wrote:*   

> I lost 1 gallon of sweat - the price to pay for being a newbie - but finally I could make that thing work. Thanks A LOT!!! If one day I become millionaire, I'll give my ten percent to you.

 

Das schmeckt mir gut!

----------

## eduardo451

I am having a similar problem, but with a twist.  Whether I have support for my card built into the kernel, or configured as a module and listed in /etc/autoload.modules.d/kernel-2.6, I still must type dhcpcd to activate my internet.  If I have my driver configured as a module without a listing in autoload.modules.d, not even typing dhcpcd works as it seemed to for germanobax.  I tried deleting domainname from my default run level, as I thought that having my dns domain name set to what I made up during the installation might be screwing with it, but no dice.  Also, since my internet card is PCMCIA, I have not added net.eth0 to my default runlevel per the install manual.  Should I try this anyway?  Any other ideas? Thanks in advance.

----------

## eduardo451

Never mind.  I went ahead and added net.eth0 to my default runlevel, which fixed the problem.  It now accesses dhcp and provides an ip address during boot.  Sometimes it pays to not follow the rules.  The manual should at least suggest adding net.eth0 if such trouble is encountered using a pcmcia card.

----------

