dhcpcd-discuss

Re: Setting static IP with dhcpcd

Roy Marples

Fri Jun 06 08:21:52 2014

Hi

On 05/06/2014 17:38, Lorrin wrote:
 I have a setup where my system is in the regular home network
connected to the router.
 The router assigns the IP to my device without issues.

 I would like to use the same IP every time for my device. Either set
it as static or as preferred.
 This is a fully controlled environment so there should be no problem
getting the preferred IP from the DHCP.

Generally you get the same IP from the server anyway, just not one you choose.

 My question is, is this possible via _dhcpcd_? Can I use a static IP
with dhcpcd at all? Or even preferred?
 I can not avoid the use of _dhcpcd_ because of some unrelated
requirements.

 What I have tried so far is to add these lines to the
_/etc/dhcpcd.conf_ file:

 interface eth0
 static ip_address=192.168.1.135/24
 static routers=192.168.1.1
 static domain_name_servers=8.8.8.8

 This is what the manpages for _dhcpcd.conf_ say:

 _STATIC VALUE_
 _ Configures a static value. If you set ip_address then dhcpcd_
 _ will not attempt to obtain a lease and just use the value for the_
 _ address with an infinite lease time._

 _ Here is an example which configures a static address, routes and_
 _ dns._
 _ interface eth0_
 _ static ip_address=192.168.0.10/24_
 _ static routers=192.168.0.1_
 _ static domain_name_servers=192.168.0.1_

Sure, this works fine
You could also use the inform option to reserve the IP address to get the reset of the config (DNS, gateway) via DHCP instead of static setup.

 But the problem is that even when I do it like this, I only get to
see my device using that IP for a short while,
 after which it seems to be lost and replaced with another IP most
probably assigned via DHCP (it is next in the pool i guess).

I tested this and it worked fine!
Nothing took the IP address.

So my question would be, can you post a dhcpcd debug log showing the initial address assignment upto the address "being lost". I would guess a 3rd party is removing it and not dhcpcd itself, or trying to claim it and dhcpcd drops it. Is 192.168.1.135 from inside the DHCP pool? As your DHCP server could be handing it to another host.

Roy

References:
Setting static IP with dhcpcdLorrin
Archive administrator: postmaster@marples.name