# Problems withs dhcpcd on a dedicated server hosted by Strato

## alfred

Hi,

I had some problems with the dhcpcd version 3.0.16-r1 on a dedicated server hosted by Strato (Berlin, Germany).

In normal cases these servers get the IP-Address and the routing table from a DHCP-Server.

Until the last reboot this morning I used a dhcpcd version 2.0.5-r1.

The addresses and routing tables resulted are:

```
0 sarah:~ # ip a

1: lo: <LOOPBACK,UP,10000> mtu 16436 qdisc noqueue

    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo

2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast qlen 1000

    link/ether 00:30:48:56:c6:36 brd ff:ff:ff:ff:ff:ff

    inet 85.214.73.141/32 brd 85.214.73.141 scope global eth0

3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop qlen 1000

    link/ether 00:30:48:56:c6:37 brd ff:ff:ff:ff:ff:ff

0 sarah:~ # ip r

85.214.73.141 dev eth0  scope link

85.214.64.1 dev eth0  scope link

127.0.0.0/8 dev lo  scope link

default via 85.214.64.1 dev eth0

```

Some time ago I emerged version 3.0.16-r1 of dhcpcd.

After the reboot this morning my server got only an address, but no valid routing table, so

I had no network access to my server (only serial). After some confusion I reemerged

the old version of dhcpcd, 2.0.5-r1, started it, and everything works fine.

I think, a new version of dhcpcd should be able to handle this (little strange) network.

As a workaround I'm using now a static address and routing table.

----------

## UberLord

Could you email a wireshark trace of the dhcpcd-3 requests to me at uberlord@gentoo.org please?

From your routing table it looks like it added a "magic" route to the router.

The correct solution is for the ISP to provide a static host route or use CSR's.

----------

## nixchecker

same provider, same problem  :Sad: 

----------

## eXtIO

We have the same problem, too  :Smile: 

Do you still need a packet trace? We can create one for you, but our box has no X server. What tool can we use?

----------

## UberLord

Sorry, I do have the traces, but have been a little busy.

Anyway, the dhcp packet that comes back just contains the router, but no route to get to it.

The DHCP server needs to add a host route using the static routes option OR use CSRs.

Other ISPs do this, so there's no reason for Strato not too.

This is NOT a dhcpcd bug, it's an error in the DHCP server configuration.

----------

## alfred

And why does the old version of dhcpcd work?

We don't have any influence of the configuration of the DHCP-Server.

----------

## UberLord

The old version of dhcpcd works because it added a magic host route to the router if it was unable to add a default route to the router.

Whilst this worked for the most part, it also caused other errors.

Aside from the older dhcpcd versions you will find no other dhcp clients in Gentoo that do this either.

If you don't have influence over the DHCP server then send an email to the people who run it

For reference

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

https://forums.gentoo.org/viewtopic-t-521037-highlight-dhcpcd+route.html

----------

## amost

This is a quite old thread but the problem is still present with dhcpcd-4.0.15 and Strato. Instead of using an explicit static route I added a dhcpcd hook that solves the routing problem for me. Just add the file /lib/dhcpcd/dhcpcd-hooks/02_buggyroute with the following content:

```
check_gateway()

{

    if ip route | grep -q 'default via'; then

      # we already have a default gateway

      :

    else

      ip route add $new_routers dev eth0 scope link

      ip route add default via $new_routers

    fi

}

case "${reason}" in

BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT)       check_gateway;;

esac
```

Don't forget to emerge sys-apps/iproute2. Alternatively it is also possible to use the old 'route' command and using these lines in the hook (I am too lazy to create and test the full script...)

```
route add $new_routers dev eth0

route add default gw $new_routers
```

The above script can certainly be improved (e.g. using $interface instead of eth0, checking $new_routers for a correct IP address, ...) but it works fine for me as it is.

----------

## UberLord

dhcpcd-5.2.3 upwards should work with this now.

We scan the routes given and if an unreachable router is there we add a host route to it, which should fix this.

----------

## arthapex

 *UberLord wrote:*   

> dhcpcd-5.2.3 upwards should work with this now.
> 
> We scan the routes given and if an unreachable router is there we add a host route to it, which should fix this.

 

It does not here, using dhcpcd-5.2.7. 

While using the two above route commands successfully establishes the connection.

Do you have some best practice advice? Do you need some more information to get it working right?

----------

## UberLord

 *arthapex wrote:*   

>  *UberLord wrote:*   dhcpcd-5.2.3 upwards should work with this now.
> 
> We scan the routes given and if an unreachable router is there we add a host route to it, which should fix this. 
> 
> It does not here, using dhcpcd-5.2.7. 
> ...

 

A full tcpdump of the DHCP interaction from strato would be very helpful. Run this command in one terminal

tcpdump -s0 -w/tmp/dhcp.raw -ieth0

once that is running, then run dhcpcd in another terminal with the -dB options.

Once configured, either correctly or incorrectly send me the dhcpcd output and the dhcp.raw file to roy@marples.name.

----------

