You are not logged in.

#1 2018-08-04 15:44:58

newsboost
Member
Registered: 2016-07-24
Posts: 157

["SOLVED"] Confused about DHCPCD - not renewing lease "2 IP addresses"

Hi all,

I'm very confused about DHCPCD, because I'm running DDWRT and made DHCP-reservation (I think it's called) using the MAC-address of my network card, by adding an extra line to dnsmasq.conf (implying that this NIC should always get the same IP address from the DHCP-server - unlike static reservation). I've rebooted the router several times. Now on my client pc I have IP 192.168.1.145. I've several times had success with "dhcpcd -k" followed by "dhcpcd". It does not seem to have the correct effect, despite the output of DHCPCD, please see below:

# dhcpcd --version
dhcpcd 7.0.5
Copyright (c) 2006-2018 Roy Marples
Compiled in features: INET ARP ARPing IPv4LL INET6 DHCPv6 AUTH


[root@HPpc martin]# ifconfig eno1 | grep -i "inet "
        inet 192.168.1.145  netmask 255.255.255.0  broadcast 192.168.1.255


[root@HPpc martin]# dhcpcd -k
sending signal ALRM to pid 7879
waiting for pid 7879 to exit


[root@HPpc martin]# ps -fe |grep -i dhcpcd
root      8935  5030  0 17:33 pts/0    00:00:00 grep -i dhcpcd


[root@HPpc martin]# systemctl status dhcpcd.service
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2018-08-04 17:33:21 CEST; 11s ago
  Process: 8929 ExecStop=/usr/bin/dhcpcd -x (code=exited, status=1/FAILURE)
  Process: 7878 ExecStart=/usr/bin/dhcpcd -q -b (code=exited, status=0/SUCCESS)
 Main PID: 7879 (code=exited, status=0/SUCCESS)

Aug 04 17:33:20 HPpc dhcpcd[7879]: received SIGALRM, releasing
Aug 04 17:33:20 HPpc dhcpcd[7879]: virbr0-nic: removing interface
Aug 04 17:33:20 HPpc dhcpcd[7879]: virbr0: removing interface
Aug 04 17:33:21 HPpc dhcpcd[7879]: enp4s0: removing interface
Aug 04 17:33:21 HPpc dhcpcd[7879]: eno1: removing interface
Aug 04 17:33:21 HPpc dhcpcd[7879]: dhcpcd exited
Aug 04 17:33:21 HPpc dhcpcd[8929]: dhcpcd not running
Aug 04 17:33:21 HPpc systemd[1]: dhcpcd.service: Control process exited, code=exited status=1
Aug 04 17:33:21 HPpc dhcpcd[8929]: dhcpcd not running
Aug 04 17:33:21 HPpc systemd[1]: dhcpcd.service: Failed with result 'exit-code'.


[root@HPpc martin]# dhcpcd
dev: loaded udev
DUID 00:01:00:01:22:28:75:42:68:05:ca:3e:bc:f8
eno1: IAID ca:3e:bc:f8
enp4s0: waiting for carrier
virbr0: waiting for carrier
virbr0-nic: waiting for carrier
eno1: soliciting an IPv6 router
eno1: rebinding lease of 192.168.1.50
eno1: leased 192.168.1.50 for 86400 seconds
eno1: adding route to 192.168.1.0/24
eno1: adding default route via 192.168.1.1
forked to background, child pid 9017


[root@HPpc martin]# ifconfig eno1 | grep -i "inet "
        inet 192.168.1.145  netmask 255.255.255.0  broadcast 192.168.1.255


[root@HPpc martin]# systemctl restart dhcpcd 


[root@HPpc martin]# ifconfig eno1 | grep -i "inet "
        inet 192.168.1.145  netmask 255.255.255.0  broadcast 192.168.1.255


[root@HPpc martin]# systemctl status dhcpcd
● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/usr/lib/systemd/system/dhcpcd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2018-08-04 17:35:13 CEST; 13s ago
  Process: 8929 ExecStop=/usr/bin/dhcpcd -x (code=exited, status=1/FAILURE)
  Process: 9185 ExecStart=/usr/bin/dhcpcd -q -b (code=exited, status=0/SUCCESS)
 Main PID: 9017 (dhcpcd)
    Tasks: 0 (limit: 4915)
   Memory: 24.0K
   CGroup: /system.slice/dhcpcd.service
           ‣ 9017 dhcpcd

Aug 04 17:35:13 HPpc systemd[1]: Starting dhcpcd on all interfaces...
Aug 04 17:35:13 HPpc dhcpcd[9185]: sending commands to master dhcpcd process
Aug 04 17:35:13 HPpc systemd[1]: Started dhcpcd on all interfaces.

What i REALLY don't understand is that "dhcpcd" actually tells (correctly) that the lease from dnsmasq/the router is or should be 192.168.1.50 - but constantly, the IP address does not become changed after killing dhcpcd (with -k) and (re-)starting dhcpcd again, the client IP address keeps being 192.168.1.145 - instead of 192.168.1.50 like the reservation says... I even tried the following, also with no apparent effect:

  596  mv /var/lib/dhcpcd/dhcpcd-eno1.lease /tmp
  600  mv /var/lib/dhcpcd/eno1.lease /tmp

I don't get it (I'm sure a reboot would help, but I still believe it should be possible without rebooting)! Please let me understand or know why this happens (and preferably what is the reason for this, so I can avoid this problem in the future). I would be VERY grateful for good input here, thanks!


UPDATE: I first marked this solved as I thought this was my solution: "ip addr change 192.168.1.145/24 dev eno1 valid_lft 30 preferred_lft 30" (cannot set lifetime to 0 seconds) - but after working with the pc for some hours once again networkmanager asks my router for a lease - and seem to obtain it from the router? So this is really strange... But my solution seem to work for several hours (hence I marked subject as "solved" because if somebody knows how to really solve this issue it would be the best for me)...

Last edited by newsboost (2018-08-05 01:37:58)

Offline

#2 2018-08-04 15:59:43

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,919

Re: ["SOLVED"] Confused about DHCPCD - not renewing lease "2 IP addresses"

sounds more like a dnsmasq problem then a dhcpcd problem.

Check /var/lib/misc/dnsmasq.leases on the server/ddwrt device.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#3 2018-08-04 16:04:08

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 19,785

Re: ["SOLVED"] Confused about DHCPCD - not renewing lease "2 IP addresses"

You might try deleting all your lease files.
Is your host name set correctly?  What host name is the router associating with your system?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

#4 2018-08-04 18:11:48

newsboost
Member
Registered: 2016-07-24
Posts: 157

Re: ["SOLVED"] Confused about DHCPCD - not renewing lease "2 IP addresses"

Lone_Wolf wrote:

sounds more like a dnsmasq problem then a dhcpcd problem.

Check /var/lib/misc/dnsmasq.leases on the server/ddwrt device.

I think it is correct, my issue could be related to dnsmasq - but I don't know how to be sure... So, I have this strange issue with my main desktop PC (Arch Linux) where dhcpcd correctly tells me the IP address should be 192.168.1.50 - but "ifconfig" says something else, another IP address. I've never before tried that ifconfig didn't tell me the right IP address - but this seems to happen now...

I'm not that experienced with DDWRT, but this is what I get:

# ls -lart  /var/lib/misc/dnsmasq.leases
ls: /var/lib/misc/dnsmasq.leases: No such file or directory

# cat /tmp/dnsmasq.leases 
...
86400 68:05:ca:3e:bc:f8 192.168.1.50 HPeliteIntelLAN ff:ca:3e:bc:f8:00:01:00:01:22:28:75:42:68:05:ca:3e:bc:f8
...

This looks correct... Strangely enough, I just tried to login to the router and "ping HPeliteIntelLAN":

root@router:~# ping HPeliteIntelLAN
PING HPeliteIntelLAN (192.168.1.50): 56 data bytes
64 bytes from 192.168.1.50: seq=0 ttl=64 time=0.375 ms
64 bytes from 192.168.1.50: seq=1 ttl=64 time=0.329 ms
64 bytes from 192.168.1.50: seq=2 ttl=64 time=0.364 ms
^C
--- HPeliteIntelLAN ping statistics ---
3 packets transmitted, 3 packets received, 0% packet loss
round-trip min/avg/max = 0.329/0.356/0.375 ms

Now I'm thinking? Huh, it's correctly pinging the pc? Let me double-check the output from "ifconfig" on the client:

# ifconfig eno1 | grep -i "inet "
        inet 192.168.1.145  netmask 255.255.255.0  broadcast 192.168.1.255

No, still the same crap - ifconfig tells me the wrong IP address, is this really true? So now I'm thinking: Is it just "ifconfig" that is reporting a wrong IP address to me? It must be, let me double-check (I just learned this new command):

# nmap -sn 192.168.1.1 --packet-trace
Starting Nmap 7.70 ( https://nmap.org ) at 2018-08-04 20:00 CEST
SENT (0.0673s) ARP who-has 192.168.1.1 tell 192.168.1.50
RCVD (0.0675s) ARP reply 192.168.1.1 is-at 9C:3D:CF:8B:87:04
NSOCK INFO [0.1040s] nsock_iod_new2(): nsock_iod_new (IOD #1)
NSOCK INFO [0.1040s] nsock_connect_udp(): UDP connection requested to 192.168.1.1:53 (IOD #1) EID 8
NSOCK INFO [0.1040s] nsock_read(): Read request from IOD #1 [192.168.1.1:53] (timeout: -1ms) EID 18
NSOCK INFO [0.1040s] nsock_write(): Write request for 42 bytes to IOD #1 EID 27 [192.168.1.1:53]
NSOCK INFO [0.1040s] nsock_trace_handler_callback(): Callback: CONNECT SUCCESS for EID 8 [192.168.1.1:53]
NSOCK INFO [0.1040s] nsock_trace_handler_callback(): Callback: WRITE SUCCESS for EID 27 [192.168.1.1:53]
NSOCK INFO [0.1050s] nsock_trace_handler_callback(): Callback: READ SUCCESS for EID 18 [192.168.1.1:53] (62 bytes): .3...........1.1.168.192.in-addr.arpa..................router.
NSOCK INFO [0.1050s] nsock_read(): Read request from IOD #1 [192.168.1.1:53] (timeout: -1ms) EID 34
NSOCK INFO [0.1050s] nsock_iod_delete(): nsock_iod_delete (IOD #1)
NSOCK INFO [0.1050s] nevent_delete(): nevent_delete on event #34 (type READ)
Nmap scan report for router (192.168.1.1)
Host is up (0.00023s latency).
MAC Address: 9C:3D:CF:8B:87:04 (Netgear)
Nmap done: 1 IP address (1 host up) scanned in 0.12 seconds

Ok, conclusion: "ifconfig" is really lying to me... Did I overlook something? Any of the other interfaces grapped the 192.168.1.50 IP-address on my Arch pc?

# ifconfig  | grep -i "inet "
        inet 192.168.1.145  netmask 255.255.255.0  broadcast 192.168.1.255
        inet 127.0.0.1  netmask 255.0.0.0
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255

No "ifconfig" is lying to me... Why is it doing that? How about my other option, I know one other command that should tell me the IP address of the eno1-interface, does it tell me the same as "ifconfig" or the real IP address as handed out by dnsmasq/the router and as reported by dhcpcd?

# ip addr show eno1
3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 68:05:ca:3e:bc:f8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.145/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1
       valid_lft 74963sec preferred_lft 74963sec
    inet 192.168.1.50/24 brd 192.168.1.255 scope global secondary noprefixroute eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::5171:7f71:e5b2:91d3/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Damn! This also says my IP address is 192.168.1.145...

EDIT/UPDATE: I just realize that the "ip addr show" command outputs 2 IP addresses for my eno1-interface and one of them is the IP address I also expect my system to have:

    inet 192.168.1.145/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1        valid_lft 74963sec preferred_lft 74963sec
    inet 192.168.1.50/24 brd 192.168.1.255 scope global secondary noprefixroute eno1       valid_lft forever preferred_lft forever

I sometimes experience crazy stuff  after I've updated my kernel, but not rebooted yet... I would like to understand/learn how to make the system completely erase/forget about the IP-address 192.168.1.145... Deleting the lease-files didn't seem to help... It's like the lease's are "cached in memory" or like this 192.168.1.145-lease is cached in memory, even though I want to get completely rid of it... Also I don't understand the scope global dynamic / global secondary stuff...

My worst problem is over now, because I can access my NFS-shares etc... I've learned now that I should never trust the "ifconfig"-output.... But I would like to understand / learn from my mistake here, so I hope someone can help understanding this problem...... Thanks!

Last edited by newsboost (2018-08-04 18:22:58)

Offline

#5 2018-08-04 18:18:35

newsboost
Member
Registered: 2016-07-24
Posts: 157

Re: ["SOLVED"] Confused about DHCPCD - not renewing lease "2 IP addresses"

ewaller wrote:

You might try deleting all your lease files.
Is your host name set correctly?  What host name is the router associating with your system?

I think it didn't change anything... But the good news is that dhcpcd didn't lie, I thought it lied to me because I've never tried that ifconfig - nor "ip addr" lies to me about my IP address.... I tried to follow your suggestion, I think you meant something like this:

# ls /var/lib/dhcpcd/
dhcpcd-enp4s0.lease  duid                 enp4s0.lease         
dhcpcd-xenbr0.lease  eno1.lease           secret               


[root@HPpc martin]# mv /var/lib/dhcpcd/*.lease /tmp


[root@HPpc martin]# ls -latr /var/lib/dhcpcd/
total 16
-r--------  1 root root  192 Feb 27 21:00 secret
-rw-r--r--  1 root root   42 Feb 27 21:00 duid
drwxr-xr-x 51 root root 4096 Aug  4 00:00 ..
drwxr-xr-x  2 root root 4096 Aug  4 20:12 .


[root@HPpc martin]# dhcpcd -k
sending signal ALRM to pid 9017
waiting for pid 9017 to exit


[root@HPpc martin]# dhcpcd
dev: loaded udev
DUID 00:01:00:01:22:28:75:42:68:05:ca:3e:bc:f8
eno1: IAID ca:3e:bc:f8
enp4s0: waiting for carrier
virbr0: waiting for carrier
virbr0-nic: waiting for carrier
eno1: soliciting an IPv6 router
eno1: soliciting a DHCP lease
eno1: offered 192.168.1.50 from 192.168.1.1
eno1: leased 192.168.1.50 for 86400 seconds
eno1: adding route to 192.168.1.0/24
eno1: adding default route via 192.168.1.1
forked to background, child pid 27795


[root@HPpc martin]# ifconfig  | grep -i "inet "
        inet 192.168.1.145  netmask 255.255.255.0  broadcast 192.168.1.255
        inet 127.0.0.1  netmask 255.0.0.0
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255


# ip addr show eno1
3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 68:05:ca:3e:bc:f8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.145/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1
       valid_lft 74311sec preferred_lft 74311sec
    inet 192.168.1.50/24 brd 192.168.1.255 scope global secondary noprefixroute eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::5171:7f71:e5b2:91d3/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

Oh, sorry... The last command tells me these two lines:

    inet 192.168.1.145/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1        valid_lft 74311sec preferred_lft 74311sec
    inet 192.168.1.50/24 brd 192.168.1.255 scope global secondary noprefixroute eno1       valid_lft forever preferred_lft forever

What's the difference between these two lines? So it seems like the IP address I really wanted my arch linux system to have is "secondary" - and the 192.168.1.145 is "dynamic"? I don't understand this output, I hope one of you network experts could please shed some light on this, thanks all, seems like we're getting close to a solution/understanding now, after all! :-)

EDIT/UPDATE: I've been googling around. I think it seems like "network-manager" doesn't want to forget the IP address and therefore my eno1-NIC now has 2 IP addresses, both seems to be fully working... It's like a network bridge, isn't it? Here's a screenshot from network-manager, which apparantly refuses to accept my newest lease:
networkmanager

Last edited by newsboost (2018-08-04 18:44:02)

Offline

#6 2018-08-04 19:07:42

newsboost
Member
Registered: 2016-07-24
Posts: 157

Re: ["SOLVED"] Confused about DHCPCD - not renewing lease "2 IP addresses"

Hello all,

I just found the solution: My understanding is that when Networkmanager has some stuff running in the background while using a window manager, hence dhcpcd -k will release and obtain a new IP address. But due to some kernel-stuff (???) or lowlevel stuff Networkmanager has higher priority and it doesn't forget the old IP lease... Hence this is the solution I came up with, found by googling around, I hope you agree this is an excellent solution (I'm just changing the fields       valid_lft 71811sec preferred_lft 71811sec and setting them to something low, e.g. 30 seconds - could probably be even lower and maybe also 0 seconds):

# ip a s dev eno1
3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 68:05:ca:3e:bc:f8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.145/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1
       valid_lft 71811sec preferred_lft 71811sec
    inet 192.168.1.50/24 brd 192.168.1.255 scope global secondary noprefixroute eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::5171:7f71:e5b2:91d3/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever


[root@HPpc Downloads]# ip addr change 192.168.1.145/24 dev eno1 valid_lft 30 preferred_lft 30


[root@HPpc Downloads]# ip a s dev eno1
3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 68:05:ca:3e:bc:f8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.145/24 brd 192.168.1.255 scope global dynamic noprefixroute eno1
       valid_lft 24sec preferred_lft 24sec
    inet 192.168.1.50/24 brd 192.168.1.255 scope global secondary noprefixroute eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::5171:7f71:e5b2:91d3/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever


[root@HPpc Downloads]# ip a s dev eno1
3: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 68:05:ca:3e:bc:f8 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.50/24 brd 192.168.1.255 scope global noprefixroute eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::5171:7f71:e5b2:91d3/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

So you see: In the end there's only 1 IP address + ifconfig now correctly reports the expected IP address.... I'm very happy now, I definately learned a lesson now (if you have other solutions/explanations, I would love to read that too) :-)

Last edited by newsboost (2018-08-04 19:09:14)

Offline

#7 2018-08-05 13:21:25

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,919

Re: ["SOLVED"] Confused about DHCPCD - not renewing lease "2 IP addresses"

Try stopping networkmanager before running dhcpcd -k .


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#8 2018-08-05 23:57:12

newsboost
Member
Registered: 2016-07-24
Posts: 157

Re: ["SOLVED"] Confused about DHCPCD - not renewing lease "2 IP addresses"

Lone_Wolf wrote:

Try stopping networkmanager before running dhcpcd -k .

You're right, good idea, I didn't thought about that... I assume you mean "systemctl stop NetworkManager.service", but the problem went away (for now), probably because the old lease timed out... I'll remember to try to stop NetworkManager.service the next time, thanks, good point...

Offline

Board footer

Powered by FluxBB