# No DHCP response from router

## nova13

This is either a networking, hardware, or kernel problem, but since I don't know which I guess I'll start here.

My (desired) network setup is as follows: A gentoo box and a windows box connected to a router which is in turn connected to my cable modem.  The windows box has no trouble connecting to the router, but the gentoo box won't.  Using the "-d" flag with dhcpcd, I see a steady stream of DHCP_DISCOVERs going out but no responses back (even in tcpdump).  

I tried a static ip with the router as the default gateway, but that didn't work either.  With the static ip, I used "arping2 192.168.2.1" to ping the router.  A packet sniffer on the windows box shows that the ARP packets are indeed going out over the subnet, but neither arping2 nor tcpdump show a response coming into the linux box.

I also tried connected the gentoo box directly to the windows box with a crossover cable, and I get the same behavior.  With or without dhcp, the gentoo box acts like it's not receiving any packets even though the packet sniffer on the windows box shows that it's sending and receiving packets to/from the gentoo box.

So you'd think there's something wrong with the network adapter, but when I connect the gentoo box directly to the cable modem - voila!  It sets up a connection with dhcp.  Ive switched network cables, tried different ports on the router, everything I can think of.

My network adapter is detected by lspci as "Realtek Semiconductor Co., Ltd. RTL-8169 Gigabit Ethernet (rev 10)", and the r8169 module is loaded.

Any suggestions on how to troubleshoot this?

----------

## didymos

If this is >=dhcpcd-3.1.3, try using the '-I' flag.  It sounds like something else is going on, but I figure it's worth a shot.

----------

## nova13

 *Quote:*   

> If this is >=dhcpcd-3.1.3, try using the '-I' flag.

 

It's dhcpcd-3.0.16, but I tried it anyway with various lease times ranging from 30 sec to infinity.  I should mention I also tried using dhclient and udhcpc with their default configurations, and that didn't work either.  I also used the packet sniffer on windows to compare the gentoo DHCP packets to the DHCP packets that the windows machine was using, and set up dhclient.conf so that they were as nearly identical as I could make them (other than machine-specific details like the hardware address and hostname).

What really baffles me is that the static config doesn't work.  Isn't it as simple as using

```
config_eth0=("192.168.2.2/24")

routes_eth0=("default via 192.168.2.1")
```

in /etc/conf.d/net?

When I did this, /etc/init.d/net.eth0 started successfully and the routing table (netstat -rn) looked right, but I could get no ICMP or ARP ping response (using ping or arping2).  Interestingly, when I pinged the win box, I saw the pings coming in and going out....

I wonder if it's something to do with r8169, but have no idea how to debug it and I haven't found any relevant bug reports on google.

----------

## nova13

Booted the gentoo box in windows, and I get the same behavior.  It doesn't work with DHCP and it doesn't work with a static ip.  On its side of the connection I see packets going out but nothing coming back.  On the other side, I see packets coming and going.

So it's not the kernel.  I guess it could still be the driver, if the Windows driver is similar. I'd guess it's the network adapter, but then how is it able to connect to the cable modem and how can I use that info to get it to connect to the router?

----------

## didymos

I'd suspect it's some setting on the router, but I have no idea what that would be (and even if I knew the make and model, still wouldn't, as I don't own any routers).

----------

## nova13

I thought so too, initially, but I had trouble connecting it to a different router as well, and it won't connect directly to another pc even with static addressing!  I guess I'll be buying a new NIC....

----------

## nova13

Ok, I had a chance to look at this some more this weekend (still haven't caved and bought a new NIC).  :Smile: 

As I said before, the gentoo box gets a dhcp response from the cable modem, but seems to ignore (or not to receive) dhcp responses from the router or the windows box.  I compared the dhcp offer packets sent by the router to those sent by the cable modem and there was one glaring difference: the cable modem addresses its dhcp OFFER packet directly to my NIC, but the router uses broadcast MAC and broadcast IP.  

Is it possible that the NIC is ignoring the offer packets because they're not addressed to its MAC?  Why don't the offers even show up in tcpdump, which puts the interface in promiscuous mode?  Is there a dhcpcd/dhclient setting that might remedy this?

----------

## didymos

Have you tried updating to a newer dhcpcd yet?

----------

## username234

 *nova13 wrote:*   

> 
> 
> Is it possible that the NIC is ignoring the offer packets because they're not addressed to its MAC?
> 
> 

 

the DHCP server will never use a broadcast when assigning an IP address.  From what I've seen on the tcp dumps I've done on my systems, the easiest way to find a response the DHCP request, is to look just after the DHCP server (which I'm assuming is your router in this case) finishes arping an IP address.

In short you should see your computer send out the request.  Your router should then perform an arp on an IP address NOT in use (meaning no one should answer the arp), and the the router will send a response (using your NIC card's MAC address) back with the IP address your card has been assigned.

 *nova13 wrote:*   

> 
> 
> I compared the dhcp offer packets sent by the router to those sent by the cable modem and there was one glaring difference: the cable modem addresses its dhcp OFFER packet directly to my NIC, but the router uses broadcast MAC and broadcast IP. 
> 
> 

 

I could be wrong, but it appears to me you're confused as to what's going on here.  From your description, your Router is asking for an IP address from your cable modem, and your cable modem is responding.  When requesting an IP address, it's very unlikely that the nic card will know the mac address(s) of the DHCP server(s).  Therefore, when requesting a NIC must broadcast its request for an IP address, and then wait for a response (that will be addressed to that NIC card) before it can know what it's IP address is.

One possibility, some routers have the ability of limiting how many leases they will give out.  In this case, the router will ignore IP address requests.

As for troubleshooting you could use the following procedure (but, I'd recommend trying the last step first), if that doesn't work then the first step would be to get it working without using DHCP.  This removes some of the complexity of trying to figure out what is wrong.  Secondly I'd modify rc-update so that it does not try to bring up your card at boot (this gives you a clean slate to use after Linux has loaded).

Then for the simplest approach:

link your two computers together.

on the windows PC

set its address to 192.168.1.1 with a subnet of 255.255.255.0

note: do not forget this step, if you do Windows will auto assign itself a 169.x.x.x address (the range is actually smaller than that... I just don't remember what it is, and I'm too lazy to look it up).

then on the Linux pc type:

(assuming eth0 is your ethernet card)

```
ifconfig eth0 192.168.1.2 netmask 255.255.255.0 up 
```

then run 

```
ping 192.168.1.1 -c 10
```

if that works, then hook your Linux PC back to the router (leave the Windows PC unconnected).

(make sure to use a straight-through cable for this... the goal here is simplicity).

then in Linux run

```
ifconfig eth0 192.168.2.2 netmask 255.255.255.0 up
```

and try to ping the router.  If all goes well that should work too.

then from the prompt type

```
route add default gw 192.168.2.1
```

and try to get on the internet.

if all this works, try turning dhcp on from the command prompt.

```
 dhcpcd eth0 
```

and if dhcpcd doesn't timeout, try pinging the router, and getting access to the internet.

if everything works at this point, put the Windows PC back on and see if it can get an IP address.  If it can't then you may have more devices than IP leases (some routers let you specify the number of leases), so increase the number of leases and everything should then start to work (You can actually check this first before everything else if you want.  It'll safe some time and effort if this is really the problem).

----------

## nova13

Thanks for your suggestions, but so far no luck.

 *Quote:*   

> 
> 
> Have you tried updating to a newer dhcpcd yet?
> 
> 

 

Didn't work.

 *Quote:*   

> 
> 
>  *Quote:*   
> 
> nova13 wrote:
> ...

 

I should have been more clear about how I did these tests.  In the first test, I connected the windows box directly to the cable modem, and in the second test I connected the windows box directly to the router.  In both cases, the two devices were the only ones connected (i.e. the router was not connected to the cable modem).  Using Windows Network Monitor, I captured the packets sent/received by the windows box.  

When I observed the dhcp interaction between the win box and the cable modem, the dhcp OFFER packet from the modem was sent to the MAC address of the win box.  However, in the dhcp interaction between the win box and the router, the dhcp OFFER packet from the router was sent to the broadcast MAC and broadcast IP.  In that packet, the assigned IP address appeared only in the dhcp portion of the packet.  

The purpose of these tests, and the reason I didn't use the linux box, was to try and understand why the linux box can configure itself with dhcp when connected to the cable modem, but it cannot configure itself with dhcp when connected to the router.  I wondered what might be different between the dhcp packets coming from the modem and those from the router that makes the linux box ignore or lose those from the router.  As I said, the only notable difference is that the router uses broadcast.

 *Quote:*   

> 
> 
> on the windows PC
> 
> set its address to 192.168.1.1 with a subnet of 255.255.255.0
> ...

 

I tried this (with subnet 192.168.0.x though).  Here's the tcpdump on the linux side:

```

palantir aaron # tcpdump -i eth0

tcpdump: verbose output suppressed, use -v or -vv for full protocol decode

listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes

20:57:26.204480 arp who-has 192.168.0.1 tell 192.168.0.2

20:57:27.204317 arp who-has 192.168.0.1 tell 192.168.0.2

20:57:28.204154 arp who-has 192.168.0.1 tell 192.168.0.2

20:57:30.204977 arp who-has 192.168.0.1 tell 192.168.0.2

20:57:31.204670 arp who-has 192.168.0.1 tell 192.168.0.2

20:57:32.204508 arp who-has 192.168.0.1 tell 192.168.0.2

```

On the Windows side of the connection I see ARP requests coming in and ARP responses going out, but I never see the responses on the linux side.  The same happens if I connect the linux box to the router and set up a static ip.  I get no ARP responses when I try to ping the router.

----------

## misterbob05

might be dumb but have you checked the cables your using???

this is a really odd problem

cuz we know that that nic and driver is working because its getting the address when its connected directly to the modem but not when  connected to the router so all the processes are working like they should.

if you had another router laying around or that you could borrow from a friend i would see if swapping them out would fix it

hmm if i have anyother thoughts ill let you know

(going into networking sorry this really puzzles me)

----------

## nova13

I don't have any special equipment for testing the cables, if that's what you mean.  I've got 3 straight-through cables, and they all work to connect the win box to the router.  I don't have another router lying around, but a month or so ago I had the linux box at a relative's house and had the same problem with his router (no dhcp response).

----------

