# [SOLVED] dhcp works not properly

## roelof

Hello, 

I have a box with is connecting to a router.

The router is connecting to internet.

When i boot the system I get a ip-adres from the router.

But when i want to go to the internet I get dns failures.

How to solve this ?

RoelofLast edited by roelof on Thu Apr 08, 2010 6:47 pm; edited 1 time in total

----------

## mikegpitt

Can you post the contents of your /etc/conf.d/net and your /etc/resolv.conf?

----------

## roelof

Hello Mike, 

They both empty so something went wrong on installing.

Now google how a resolv.conf must look like.

Roelof

Edit : When I do nano -w /etc/resolv.conf

And i put this lines in it.

Search localhost

nameserver 212.54.35.25

nameserver 212.54.40.25

And I save it.

After a reboot the file is empty.

It looks like dhcpcd writes it.

And on reboot dhcpcd times out.

----------

## mikegpitt

That is correct, your resolv.conf will be overwritten on each boot by whatever dhcp places there.  The reason I was asking to see your /etc/conf.d/net is to see if you are accidentally using nodns in your dhcp configuration.

----------

## roelof

Hello, 

I don't use nodns.

The only thing what in conf.d/net is comments

Any other idea how to solve this or do I need NAT because im behind a router ?

Roelof

----------

## mikegpitt

Is your router set to send you its default nameservers?  Perhaps you haven't configured this option on your router?  Also, can you post the version of dhcpcd you are using (or whatever dhcp client you are using)?

----------

## roelof

Hello, 

DHCPCD is version 4.0.15.

In Windows the router is sending the nameservers with it,

So I think that in Gentoo it's the same.

In the router config there is nothing about sending dns data.

Roelof

----------

## mikegpitt

How are you starting your network adapter at boot?  Have you manually added net.eth0 to your default renlevel, are you letting something like netplug start it, or something else?

Also, are you sure that with the ip address your router gives you, you are able to ping external addresses?  You might want to try and ping your router for starters, and then try something on the net like google.com (72.14.209.104).

----------

## roelof

Hello Mike, 

Here the data you asked for and a little bit more.

I have manually added eth0 to the default runlevel as stated in the book.

Here the ping results :

ping 192.168.0.1 (router)  connect : network unreachable

ping 72.14.209.104           connect : network unreachable

ping www.google.nl           ping : unknown host www.google.com

And here is ifconfig :

```

eth0 link encap : UNSPEC HWadres : a lot of numbers and letters.

        inet addr : 169.254.126.196 Bcast : 169.254.255.255 mask : 255.255.0.0

        UP BROADCAST RUNNING MULTICAST MTU:1500 METRIC:1

        RX packets : 0  errors : 0   dropped : 0 overruns : 0 frame:0 

        TX packets : 38 errors : 0   dropped: 0 overruns : 0 carrier:0 collisions : 0  txqueulelen : 1000

        RX packets : 0 (0,0 b)    TXbytes: 11335 (11,0 Kib)

```

And on booting I see this messages : 

```

dhcpcd 4.0.15 starting 

broadcasting  for lease

timed out

trying to use old lease in 'var/lib/dhcpcd/dhcpcd-eth0.lease'

checking 169.254.126.196 is avaible on attached networks.

Using IPv4LL adres 169.254.126.196

   eth0 recieved adress 169.254.126.196

```

Roelof

----------

## mikegpitt

Ok, so it looks like the issue isn't that you aren't getting your dns settings, it's that you aren't getting a proper ip address.  The one it is assigning you is the one dhcp has in its cache.

I'm not 100% sure where to go from here, but some things that you might want to check are:

1) Ensure your ethernet cable works well  (a good test would be to see if you get an ip when booting off a gentoo minimal cd)

2) Verify that you are using the correct drivers for your card in the kernel  (Can you post the results of `lspci -nn | grep Network`)

3) Ensure that you don't have firewall settings blocking the dhcp request

----------

## roelof

Hello Mike, 

1) I have a working internet when using rescuedisk after doing net-setup eth0

2) lscpi -nn | grep Network gives nothing.

     lspci -nn gives this on networking: 

     02:03.0 Ethernet controller [0200]: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ [10ec:8139] (rev 10)

3) I don't think that's the problem. With the same computer on Windows no problem and in the config of the router nothing can be found on blocking DNS.

Roelof

----------

## gerard27

Have you done "Copy DNS Info" from the handbook?

You can still do it with rescuecd.

Do net-setup eth0 with rescuecd and then

chroot into your install.

Gerard.

----------

## roelof

Hello Gerard.

Oke and then ?

What must I do after chrooting.

I have done "Copy DNS info" from the handbook.

Roelof

----------

## gerard27

Are you sure it's copied to your /etc/resolv.conf?

Then you exit the chroot,unmount and remove the rescuecd and reboot.

Gerard.

----------

## roelof

Hoi Gerard.

Im sure I copied it.

That's where I find the problems that I described.

After rebooting dhcp will rewrite resolv.conf

Roelof

----------

## gerard27

Apparently /etc/resolv.conf is not important.

I did the following:

I moved resolv.conf out of /etc.

I then did /etc/init.d/net.eth0 restart.

To my surprise it connected w/o any problem.

It's been a long time since I had to config this.

But I did my regular updates and things might have changed.

One last question:did you compile the 8139 driver in-kernel or as a module?

Gerard.

----------

## mikegpitt

I still think the problem is not dns, but with your dhcp client not receiving an ip for some reason.  BTW - When I asked about the firewall above, I meant the firewall on your local machine, not on your router...  Sometimes if the local firewall is not configured properly it will block all net connections.

A kernel misconfiguration still seems like it could be an option.  Maybe you should try copying over the kernel configuration off the livecd and reconfigure your kernel.  You can use this command to get the kernel .config off the livecd (when you are booted into the livecd):  `zcat /proc/config.gz > .config`

----------

## roelof

Hello Mike, 

Kernel misconfig I don't think so. The config is made by pappa_mcfea

I can see that the modules for the network card are modules and both modules are loaded on start.

With lsmod I see this  :

8139cp  22616   0 

8139too  27260  0 

Roelof

----------

## gerard27

The 8139cp is prolly the culprit.

I used to have a box with the 8139 and in make menuconfig I had a choice of 2 8139 modules.

I remember that only the one option that resulted in 8139too worked.

You might try 

```

modprobe -r 8139cp
```

and then

```

etc/init.d/net.eth0 restart
```

Gerard.

----------

## roelof

Hello Gerard, 

Did your steps but still the same messages.

Roelof

----------

## gerard27

What message did you get after modprobe -r?

Gerard.

----------

## roelof

Hello Gerard, 

I get no message , just the prompt.

But the module disappear on the list generated by lsmod.

Roelof

----------

## gerard27

OK.

Plse do rc-status and post the result.

Gerard.

----------

## mikegpitt

Try removing both modules and adding the 8139too module:

```

rmmod 8139cp

rmmod 8139too

modprobe 8139too

```

----------

## roelof

Hello Mike and Gerard.

Gerard 

Here's the output of rc-status.

local    started

net.eth0 started

netmount  started

udev.postmount started.

Mike,

If I do your steps and restarted eth0 the problem stays.

Roelof

----------

## gerard27

Is that all you get from rc-status?

Gerard.

----------

## roelof

Hello Gerard, '

Yes, that all there is on the booted system.

Or did you want a rc-status on the chrooted enviroment.

Roelof

----------

## gerard27

Here's mine:

```

Runlevel: default

 sysklogd                                                          [  started  ]

 gpm                                                               [  started  ]

 dbus                                                              [  started  ]

 acpid                                                             [  started  ]

 consolekit                                                        [  started  ]

 hald                                                              [  started  ]

 net.eth0                                                          [  started  ]

 netmount                                                          [  started  ]

 xdm                                                               [  started  ]

 clamd                                                             [  started  ]

 ntp-client                                                        [  started  ]

 cupsd                                                             [  started  ]

 ntpd                                                              [  started  ]

 udev-postmount                                                    [  started  ]

 local                                                             [  started  ]

Dynamic Runlevel: hotplugged

Dynamic Runlevel: needed

 udev-mount                                                        [  started  ]

 xdm-setup                                                         [  started  ]

Dynamic Runlevel: manual

```

If that what you posted is all then you should consult the handbook again.

Compare mine to yours.

Gerard.

----------

## mikegpitt

 *roelof wrote:*   

> did you want a rc-status on the chrooted enviroment.
> 
> Roelof

 Wait...  are you trying to use dhcp inside your chrooted environment, or inside your regular system?

----------

## roelof

Oke, 

But you have a full installed system.

I just a minium installed system.

dbus and hal are installed by Xorg.

cups is not installed on my system.

consolekit is installed by gnome.

That are all steps I have to do.

Roelof

----------

## roelof

Hello Mike, 

I use dhcp inside my regular system.

Roelof

----------

## gerard27

Having things just installed is not enough!

They should also be running.

Gerard.

----------

## roelof

Hello Gerard, 

What does this remark help on solving the problem ?

You cannnot compare a full installation with a just installed stage 3 tarball installation.

Roelof

Edit : I try to boot without the router . Just the computer connected to the modem.

But still the same problem. So the router is not the problem.

----------

## gerard27

You're missing hald and dbus in your default runlevel.

I don't know what is in your bootlevel.

That's why I recommended checking the handbook.

Gerard.

----------

## roelof

Hello Gerard.

Hald en Dbus are installed when you install X.

X is not yet installed and with a not working internet I couldn't install X.

Roelof

----------

## gerard27

Installed is not enough.

They should be running.

In your default runlevel you don't have dbus,hald or acpid.

dmesg might give a clue as to what goes wrong.

Just type dmesg | less in a console and check for info on 8139.

The 8139 is about the best supported ethernet card in Linux.

You can use pge-dwn and -up to browse dmesg | less.

Gerard.

----------

## roelof

Hello Gerard. 

I think we found it.

In dmesg I found this messages.

8139too Fast Ethernet Driver

8139too <a lot of numbers> PCI int A -> GSI 20 (level, low) -> IRQ 20

eth1 : Realtek RTL8139 at < a lot of numbers>

<6> 8139cp <a lot of numbers> 10/100 PCI Ethernet Driver v1.3

So the card is named eth1 where DHCP is looking for eth0

Roelof

----------

## mikegpitt

 *roelof wrote:*   

> 
> 
> So the card is named eth1 where DHCP is looking for eth0
> 
> Roelof

 That is odd, because in a previous post your ifconfig output listed the card as eth0, unless you have multiple network cards on your machine.  An `ifconfig -a` will display all the cards even if they are inactive.

I would recommend installing netplug and take net.eth0/1 out of your default runlevel.  Netplug will handle your connections just fine.

I take if that you are able to get an ipaddress using eth1 now?

About gerard82's comments...  you don't need hal/dbus/acpi for a working system.  Yes, most systems have this installed (and running) but they are definitely not necessary.  I'm not exactly sure what those services would add to help this situation either.

----------

## roelof

Oke, 

I will goto the chrooted enviroment and install netplug.

After that I will delete net.eth0 and net.eth1

I will come back and report how things works now.

Roelof

----------

## mikegpitt

 *roelof wrote:*   

> I will goto the chrooted enviroment and install netplug.
> 
> After that I will delete net.eth0 and net.eth1

 Having anything in any runlevel inside a chroot doesn't matter, since the environment isn't booted.  This is what I was getting at yesterday when I asked if you were running dhcp on your regular machine or inside chroot.  Your chroot will have the same ip address and network connectivity as your regular bootable installation.  I'm not sure if it is possible to assign a separate ip address inside chroot...

----------

## roelof

Oke, 

I did the steps, booted the installed system and also netplug finds eth0.

I think that udev has a wrong rule so that any card will be eth1 instead of eth0

Roelof

----------

## mikegpitt

 *roelof wrote:*   

> Oke, 
> 
> I did the steps, booted the installed system and also netplug finds eth0.
> 
> I think that udev has a wrong rule so that any card will be eth1 instead of eth0
> ...

 Can you post the output of `ifconfig -a` so we can see what might be going on?

If you want to change the assignment of your network interfaces, this is the file to do it in: /etc/udev/rules.d/70-persistent-net.rules

----------

## roelof

Hello, 

I already looked in the 70-persistent-net.rules.

And find out that first a firewire card is found and after that the network card.

And in the rule of the network card is stated name="eth1".

Change it to eth0 does not help.

Still want to have the output of ifconfig -a  ?

Roelof

----------

## mikegpitt

 *roelof wrote:*   

> 
> 
> Still want to have the output of ifconfig -a  ?

 No, I suppose it doesn't really matter if you are sure that eth1 is your network card.  I'm confused as to what you are trying to accomplish...  Can you answer the following?

1) Are you trying to run dhcp or start net.eth1 inside a chroot environment?

2) Now that you found that your network card is eth1, are things working?

If the answer to 1 is yes, then I'm pretty sure this is not possible.  If you answer to 2 is no, I'm still strongly leaning toward a kernel misconfiguration.  You mentioned that you are using pappy's kernel seeds, but there is always a chance that something went wrong.  I would still encourage you to rebuild your kernel using the same configuration as on the livecd to see if it helps.  BTW - What kernel are you using?

----------

## Raptor85

You could try starting the interfaces manually after rebooting to see if they're working at all, that would eliminate any confusion about where the error is.

After the reboot(not within the chrooted environment) try this.

ifconfig eth1 x.x.x.x

(obviously put a local ip address for your network here)

echo "nameserver 212.54.35.25" >> /etc/resolv.conf

and test to see if you can get a connection, if that works it's probably not your driver, you can then try this.

dhcpcd -k

dhcpcd -d eth1

and see what it returns to you, if these work your error is in the runlevel scripts, if not post the full error message up here.

----------

## roelof

Hello Mike, 

1) No, as I said im working on my newly installed system.

2) nope, it's not working.

Hello Raptor, 

After ifconfig and the echo still no connection.

after dhcpcd -k i get a message no device specified 

But after dhcpcd -d eth1 a working connection.

So it must be the runlevel scripts.

Can you or anyone else help me debug this ?

Roelof

Edit : Can we give the firewire card another name because it's no network card but a card to connect my digital camera to the computer.

----------

## roelof

Hello, 

I  solved it.

I renamed net.eth0 to net.eth1 and now everything works.

Roelof

----------

## mikegpitt

 *roelof wrote:*   

> Hello, 
> 
> I  solved it.
> 
> I renamed net.eth0 to net.eth1 and now everything works.
> ...

 Ahh... we should have checked that a while ago.  I'm still surprised netplug didn't work for you if the init script works fine.

Happy to hear things are working!

----------

