# DHCP Renews

## PP133

Hey guys, I'm having a little annoying issue with dhcpcd.  I'm not entirely sure if this has to do with my laptop or the dhcp server in my office but since I don't have this problem with any other computers using the same dhcp server, I tend to think it's my configuration.  Basically, my laptop does dhcp renews whenever it pleases.  It'll dhcp renew in the middle of the day when I have tons of ssh sessions open, disconnecting them all.

Any ideas as to what I can do?

Thx!

----------

## cjubon

intel EtherExpress pro card? eepro100 driver? 10 Mbs network?

If yes, try if the e100 driver (Intel Pro100+) works better or upgrade to a 100Mbs network.

----------

## PP133

 *cjubon wrote:*   

> intel EtherExpress pro card? eepro100 driver? 10 Mbs network?
> 
> If yes, try if the e100 driver (Intel Pro100+) works better or upgrade to a 100Mbs network.

 

```
02:00.0 Ethernet controller: Intel Corporation 82573L Gigabit Ethernet Controller
```

----------

## PP133

 *cjubon wrote:*   

> intel EtherExpress pro card? eepro100 driver? 10 Mbs network?
> 
> If yes, try if the e100 driver (Intel Pro100+) works better or upgrade to a 100Mbs network.

 

Oh, and it's a 100mbps network.

----------

## UberLord

What version of dhcpcd?

I ask as dhcpcd-3 shouldn't drop any configuration during a renew. Obviously if you end up getting a different lease then things will be as you describe, but with the same lease it should just continue  :Smile: 

----------

## PP133

 *UberLord wrote:*   

> What version of dhcpcd?
> 
> I ask as dhcpcd-3 shouldn't drop any configuration during a renew. Obviously if you end up getting a different lease then things will be as you describe, but with the same lease it should just continue 

 

```

tungsten # dhcpcd --version

dhcpcd 3.0.16

```

Maybe it's a config issue?  I really didn't do much to config dhcpcd.  And I am getting the same IP each time but I don't want to set it to static, though I might just do that if I can't get this figured out.

----------

## UberLord

3.1.5 went stable a while ago, you may also wish to try 3.1.7.

If you fail to get a DHCP address with those versions, try using dhcpcd_eth0="-I ''" or emerging with the vram USE flag set.

Try adding the -d option and see what the logs say.

Or you can be a little more hardcore and do this in one term

dhcpcd -dd eth0

Once it gets a lease, do this in another term

dhcpcd -n eth0

That will cause the dhcpcd instance running in the first term to renew it's lease and you can easily see what it's doing.

----------

## PP133

Yo, when you say "try using dhcpcd_eth0="-I ", what do you mean?  Also, what is the vram USE flag for?

I'm going to try upgrading to the newest version right now, but i have a feeling that that alone won't fix it.

----------

## UberLord

 *PP133 wrote:*   

> Yo, when you say "try using dhcpcd_eth0="-I ", what do you mean?  Also, what is the vram USE flag for?

 

Both of them do the same thing - stop dhcpcd from using a Client Node Identifier instead of the interfaces MAC address as some baldy confgiured DHCP servers don't work with this.

 *Quote:*   

> I'm going to try upgrading to the newest version right now, but i have a feeling that that alone won't fix it.

 

We will know more once you can post logs or the output of that test I told you.

----------

## PP133

Hey, sorry about the long delay in answering, I kinda forgot about this.  After I lost connection again this morning due to the release, I decided I'd get around to solving this once and for all.  Below is what happened when I ran the commands you suggested

```

tungsten / # dhcpcd -dd eth0

Info, eth0: dhcpcd 3.1.7 starting

Info, eth0: hardware address = 00:00:00:00:00:00

Info, eth0: DUID = 00:00:00:01:00:00:00:00:00:00:00:00:00:00

Info, eth0: broadcasting for a lease

Debug, eth0: sending DHCP_DISCOVER with xid 0xe44a72c

Debug, eth0: waiting on select for 20 seconds

Debug, eth0: got a packet with xid 0xe44a72c

Info, eth0: offered 172.121.122.110 from 172.121.122.11

Debug, eth0: sending DHCP_REQUEST with xid 0x0000000

Debug, eth0: waiting on select for 20 seconds

Debug, eth0: got a packet with xid 0x0000000

Info, eth0: checking 172.121.122.110 is available on attached networks

Debug, eth0: sending ARP probe #1

Debug, eth0: sending ARP probe #2

Debug, eth0: sending ARP probe #3

Debug, eth0: sending ARP claim #1

Debug, eth0: sending ARP claim #2

Info, eth0: leased 172.121.122.110 for 86400 seconds

Debug, eth0: renew in 43200 seconds

Debug, eth0: rebind in 75600 seconds

Info, eth0: adding IP address 172.121.122.110/25

Info, eth0: adding default route via 172.121.122.11 metric 0

Info, eth0: adding route to 169.254.0.0/16 metric 0

Debug, eth0: writing /etc/resolv.conf

Debug, eth0: writing /var/lib/dhcpcd/dhcpcd-eth0.info

Debug, eth0: waiting on select for 43200 seconds

Info, eth0: received SIGALRM, renewing lease

...

...

...

Info, eth0: received SIGALRM, renewing lease

Info, eth0: received SIGINT, stopping

Info, eth0: removing default route via 172.121.122.11 metric 0

Info, eth0: removing route to 169.254.0.0/16 metric 0

Info, eth0: removing IP address 172.121.122.110/25

Info, eth0: exiting

```

When I issue the `dhcpcd -n eth0` command on the other term, the "Info, eth0: received SIGALRM, renewing lease" line spams the first terminal.  It never ends.  Eventually I hit ctrl+c on the first term and I get the rest, shown above beginning with the line "...received SIGINT, stopping".

----------

## UberLord

Try 3.1.8, as I think it fixed a race with manual renews.

----------

## PP133

I installed the latest version and I do see a change in the output of the commands you asked me to run:

```

tungsten / # dhcpcd -dd eth0

Info, eth0: dhcpcd 3.1.8 starting

Info, eth0: hardware address = 00:00:00:00:00:00

Info, eth0: DUID = 00:00:00:00:00:00:00:00:00:00:00:00:00:00

Info, eth0: broadcasting for a lease

Debug, eth0: sending DHCP_DISCOVER with xid 0x615d8e17

Debug, eth0: waiting on select for 20 seconds

Debug, eth0: got a packet with xid 0x615d8e17

Info, eth0: offered 172.121.122.165 from 172.121.122.11

Debug, eth0: sending DHCP_REQUEST with xid 0x615d8e17

Debug, eth0: waiting on select for 20 seconds

Debug, eth0: got a packet with xid 0x615d8e17

Info, eth0: checking 172.121.122.165 is available on attached networks

Debug, eth0: sending ARP probe #1

Debug, eth0: sending ARP probe #2

Debug, eth0: sending ARP probe #3

Debug, eth0: sending ARP claim #1

Debug, eth0: sending ARP claim #2

Info, eth0: leased 172.121.122.165 for 86400 seconds

Debug, eth0: renew in 43200 seconds

Debug, eth0: rebind in 75600 seconds

Info, eth0: adding IP address 172.121.122.165/25

Info, eth0: adding default route via 172.121.122.1 metric 0

Info, eth0: adding route to 169.254.0.0/16 metric 0

Debug, eth0: writing /etc/resolv.conf

Debug, eth0: writing /var/lib/dhcpcd/dhcpcd-eth0.info

Debug, eth0: waiting on select for 43200 seconds

```

Then when I run `dhcpcd -n eth0`, I see the following:

```

Info, eth0: received SIGALRM, renewing lease

Info, eth0: renewing lease of 172.121.122.165

Debug, eth0: sending DHCP_REQUEST with xid 0x35268259

Debug, eth0: waiting on select for 32400 seconds

Debug, eth0: got a packet with xid 0x35268259

Info, eth0: leased 172.121.122.165 for 86400 seconds

Debug, eth0: renew in 43200 seconds

Debug, eth0: rebind in 75600 seconds

Info, eth0: removing route to 169.254.0.0/16 metric 0

Info, eth0: adding IP address 172.121.122.165/25

Info, eth0: adding default route via 172.121.122.1 metric 0

Info, eth0: adding route to 169.254.0.0/16 metric 0

Debug, eth0: writing /etc/resolv.conf

Debug, eth0: writing /var/lib/dhcpcd/dhcpcd-eth0.info

Debug, eth0: waiting on select for 43200 seconds

```

Soo, umm, now what?  :Smile: 

----------

## UberLord

Nothing wrong with that - only the IPv4LL route is removed, which you probably aren't using.

----------

## PP133

So, I just had this happen to me again today, my IP released/renewed, lost all of my connections, bah!

Any other ideas?

----------

## PP133

Below are the contents of /var/log/messages shortly after my connections dropped because of the re-lease (IP addresses changed for my protection  :Smile:  ):

```

Jan 14 14:41:58 tungsten dhcpcd[3811]: eth0: renewing lease of 72.121.122.166

Jan 14 14:41:58 tungsten dhcpcd[3811]: eth0: received NAK: (null)

Jan 14 14:41:59 tungsten dhcpcd[3811]: eth0: broadcasting for a lease

Jan 14 14:42:00 tungsten dhcpcd[3811]: eth0: offered 72.121.122.129 from 72.121.122.1

Jan 14 14:42:00 tungsten dhcpcd[3811]: eth0: checking 72.121.122.129 is available on attached networks

Jan 14 14:42:01 tungsten dhcpcd[3811]: eth0: leased 72.121.122.129 for 86400 seconds

Jan 14 14:42:01 tungsten dhcpcd[3811]: eth0: removing route to 169.254.0.0/16 metric 0

Jan 14 14:42:01 tungsten dhcpcd[3811]: eth0: adding IP address 72.121.122.129/25

Jan 14 14:42:01 tungsten dhcpcd[3811]: eth0: removing IP address 72.121.122.166/25

Jan 14 14:42:01 tungsten dhcpcd[3811]: eth0: adding default route via 72.121.122.1 metric 0

Jan 14 14:42:01 tungsten dhcpcd[3811]: eth0: netlink: Network is unreachable

Jan 14 14:42:01 tungsten dhcpcd[3811]: eth0: adding route to 169.254.0.0/16 metric 0

Jan 14 14:42:01 tungsten dhcpcd[3811]: eth0: netlink: No such device

```

Whenever this happens, in order to get back online, I have to manually run the following commands:

```

dhcpcd eth0 -k

dhcpcd eth0

```

Any ideas?

----------

## UberLord

Actually, yes I do  :Smile: 

Whilst discussing a few things with dnsmasq upstream he did raise a potential error which he had one user hit, and it looks like you've hit it too. Not many people getting it though.

Anyways, there are some cases where we don't set the serverid in the DHCP message, which I now think you may be suffering from. Here's a patch against dhcpcd-3.1.9.

It's not been tested though, nor comitted to dhcpcd source yet. Maybe you could let me know how it goes for you?

http://roy.marples.name/~roy/dhcpcd-serverid.patch

----------

## PP133

Hi, thanks for looking into this further.  Forgive my ignorance, can you explain what I'm supposed to do with the code on that URL you sent me?

Thanks again

----------

## UberLord

Edit your ebuild /usr/portage/net-misc/dhcpcd/dhcpcd-3.1.9.ebuild

Change this near the top

```
inherit toolchain-funcs
```

To this

```
inherit eutils toolchain-funcs
```

Look a few lines down for this

```

src_unpack() {

    unpack ${A}

    cd "${S}"

    if use zeroconf; then

```

And make it look like this

```
src_unpack() {

    unpack ${A}

    cd "${S}"

    epatch /patch/to/patch

    if use zeroconf; then

```

Change /path/to/patch to where you downloaded the above patch.

emerge dhcpcd

And voila - patch applied.

If any of that fails, you can do a manual install like so

```

cd /tmp

tar xvjpf /usr/portage/distfiles/dhcpcd-3.1.9

cd dhcpcd-3.1.9

patch -p1 </path/to/patch

make

install dhcpcd /sbin
```

----------

## UberLord

Did you patch OK and does it appear to be working now?

----------

## PP133

Hey, sorry for my hiatus...I just tried following your instructions but ran into some problems.  One question I have is about "path to patch", should that include the filename or just the path to the file?  If it's just the path, what should I name the file?

Assuming that "path to patch" included the filename, I made the changes to /usr/portage/net-misc/dhcpcd/dhcpcd-3.1.9.ebuild and tried emerging:

```

tungsten dhcpcd # emerge dhcpcd

Calculating dependencies |!!! Digest verification failed:

!!! /usr/portage/net-misc/dhcpcd/dhcpcd-3.1.9.ebuild

!!! Reason: Filesize does not match recorded size

!!! Got: 2451

!!! Expected: 2399                                                                                          ... done!

>>> Verifying ebuild Manifests...

!!! Digest verification failed:

!!! /usr/portage/net-misc/dhcpcd/dhcpcd-3.1.9.ebuild

!!! Reason: Filesize does not match recorded size

!!! Got: 2451

!!! Expected: 2399

```

Since that didn't work, I tried following your follow-up instructions:

 *Quote:*   

> 
> 
> If any of that fails, you can do a manual install like so
> 
> ```
> ...

 

But I don't have /usr/portage/distfiles/dhcpcd-3.1.9 to tar.  I tried skipping that line and going straight to the patch -p1 line but nothing happened.

----------

## UberLord

http://roy.marples.name/dhcpcd/dhcpcd-3.1.9.tar.bz2

You can download it directly here.

BTW, to solve the first problem you need to redigest the ebuild like so

cd /usr/portage/net-misc/dhcpcd/

ebuild dhcpcd-3.1.9.ebuild digest

----------

## UberLord

OR you can just download a pre tarball and do a manual install like so

```

wget http://roy.marples.name/dhcpcd/dhcpcd-3.1.10_pre1.tar.bz2

tar xvjpf dhcpcd-3.1.10_pre1.tar.bz2

cd dhcpcd-3.1.10_pre1

make

install dhcpcd /sbin
```

----------

## PP133

Hi, well, I downloaded that file, bunzip2, tar xvf'd it, make, make install'd it and I'm online, so it must've gone remotely well  :Smile: 

I guess i'll just wait and see if it's working now.

----------

## UberLord

FWIW, dhcpcd-3.2.0 was released today with that patch in. So hopefully you're now fixed  :Smile: 

----------

## PP133

Well, it just happened to me again.

I really get the impression that this is just something stupid.  Something that I didn't configure correctly.  I'm going to look up some basic DHCP guides.

----------

## UberLord

Are you still getting NAKs in your logs?

If so, you'll always get a new address. I'll need a tcpdump of that transaction too, so I can try to analyse why that is happening and if it's a dhcpcd problem or not. It may also be the case that the upstream dhcp server is forcing you to get a new address as well.

----------

## PP133

Hey, thx for sticking with me to troubleshoot this  :Smile: 

Here's what I saw in my logs regarding the DHCP renew attempt:

```

Jan 29 12:23:07 tungsten dhcpcd[8797]: eth0: dhcpcd 3.2.0 starting

Jan 29 12:23:07 tungsten dhcpcd[8797]: eth0: hardware address = 00:aa:aa:aa:aa:aa

Jan 29 12:23:07 tungsten dhcpcd[8797]: eth0: DUID = 00:aa:00:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa:aa

Jan 29 12:23:07 tungsten dhcpcd[8797]: eth0: broadcasting for a lease

Jan 29 12:23:07 tungsten dhcpcd[8797]: eth0: offered 72.121.122.28 from 72.121.122.1

Jan 29 12:23:07 tungsten dhcpcd[8797]: eth0: checking 72.121.122.28 is available on attached networks

Jan 29 12:23:08 tungsten dhcpcd[8797]: eth0: leased 72.121.122.28 for 86400 seconds

Jan 29 12:23:08 tungsten dhcpcd[8797]: eth0: adding IP address 72.121.122.28/25

Jan 29 12:23:08 tungsten dhcpcd[8797]: eth0: adding default route via 72.121.122.1 metric 0

Jan 29 12:23:08 tungsten dhcpcd[8797]: eth0: adding route to 169.254.0.0/16 metric 0

Jan 29 12:23:08 tungsten dhcpcd[8797]: eth0: exiting

```

----------

## UberLord

That's starting up, not renewing. Did dhcpcd die?

And yeah, I like to help people as much as possible - especially when it's my software involved  :Smile: 

----------

## PP133

I don't think dhcpcd died.  Right after I lost connection I ran `dhcpcd eth0` and it complained saying something along the lines that dhcpcd was already running for eth0.  I had to run `dhcpcd eth0 -k` and then `dhcpcd eth0` to renew.

Your software?  Eh?

----------

## UberLord

 *PP133 wrote:*   

> I don't think dhcpcd died.  Right after I lost connection I ran `dhcpcd eth0` and it complained saying something along the lines that dhcpcd was already running for eth0.  I had to run `dhcpcd eth0 -k` and then `dhcpcd eth0` to renew.
> 
> Your software?  Eh?

 

Yes, you killed dhcpcd and restarted it. Which if courses removes the IP address and routing  :Razz: 

To renew, do `dhcpcd -n eth0`

If dhcpcd is already running it will renew, otherwise it will start as normal.

----------

