You are not logged in.
I'm doing some network troubleshooting and am surprised that the machines on my wireless network always get the same "random" IP address from my router, even after I delete all the leases in /var/lib/misc/dnsmasq.leases.
The router has a startup job that creates /tmp/dnsmasq.conf and then launches dnsmasq with this command: dnsmasq -C /tmp/dnsmasq.conf. This is what /tmp/dnsmasq.conf looks like:
listen-address=192.168.10.1
bind-dynamic
dhcp-range=192.168.10.100,192.168.10.200,255.255.255.0,24h
dhcp-option-force=option:router,192.168.10.1
dhcp-option-force=option:dns-server,192.168.10.1
dhcp-option-force=option:mtu,1500
How come machines get the same IP addresses even after I manually delete /var/lib/misc/dnsmasq.leases and reboot the router? All the machines are configured to use DHCP, not a static local ip. There must be a record of prior IP addresses somewhere. Does dnsmasq have some kind of IP address cache? Maybe the Devuan ASCII computers somehow remember their prior IP address and ask for the same address again during DHCP negotiation?
Bottomline: How do I purge all memory of prior IP addresses so that all machines in my wireless network get new addresses the next time they talk to the router?
Last edited by GNUser (2019-05-19 19:15:35)
Offline
The dnsmasq man page solved the mystery of dhcp always giving particular computers particular IP addresses:
Dnsmasq is designed to choose IP addresses for DHCP clients
using a hash of the client's MAC address. This normally allows a
client's address to remain stable long-term, even if the client
sometimes allows its DHCP lease to expire.
The --dhcp-sequential-ip flag causes dnsmasq's behavior to be what I expected. Hope this helps anyone who finds themselves doing some head-scratching as I was
Offline
Alas, things are never as simple as they seem. Not only do we need 1) dhcp server sequential ip flag and 2) delete server's lease file, but there are also considerations on the client side.
It seems that dhclient is hardwired to ask for the last IP address it got. This from dhclient.conf's man page:
When the client is restarted, it first tries to reacquire the last address it had. This is called the INIT-REBOOT state. If it is still attached to the same network it was attached to when it last ran, this is the quickest way to get started. The reboot statement sets the time that must elapse after the client first tries to reacquire its old address before it gives up and tries to discover a new address. By default, the reboot timeout is ten seconds.
I tried putting reboot 0; in my computer's /etc/dhcp/dhclient.conf, but it has no effect. So I had to do this:
3) # rm /var/lib/NetworkManager/dhclient*
With 1-3 above I finally got the expected behavior of my computer getting the lowest-available IP address from the router.
But I'm not satisfied because step 3 is a hack. What I really want is a way of telling dhclient not to try to reacquire the last address it had. Any idea how to accomplish this?
Last edited by GNUser (2019-05-19 04:16:57)
Offline
What I really want is a way of telling dhclient not to try to reacquire the last address it had. Any idea how to accomplish this?
Try adding this to /etc/dhcp/dhclient.conf:
request;
See the LEASE REQUIREMENTS AND REQUESTS section of dhclient.conf(5) for more on this.
Brianna Ghey — Rest In Power
Offline
Thank you, Head_on_a_Stick. It seems NetworkManager parses /etc/dhcp/dhclient.conf then appends a few lines, to produce /var/lib/NetworkManager/dhclient-wlan0.conf. The latter file already contains request;. This is what the complete /var/lib/NetworkManager/dhclient-wlan0.conf looks like:
# Created by NetworkManager
# Merged from /etc/dhcp/dhclient.conf# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
# man page for more information about the syntax of this file
# and a more comprehensive list of the parameters understood by
# dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
# not leave anything out (like the domain name, for example), then
# few changes must be made to this file, if any.
#
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/sbin/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;
#alias {
# interface "eth0";
# fixed-address 192.5.5.213;
# option subnet-mask 255.255.255.255;
#}
#lease {
# interface "eth0";
# fixed-address 192.33.137.200;
# medium "link0 link1";
# option host-name "andare.swiftmedia.com";
# option subnet-mask 255.255.255.0;
# option broadcast-address 192.33.137.255;
# option routers 192.33.137.250;
# option domain-name-servers 127.0.0.1;
# renew 2 2000/1/12 00:00:01;
# rebind 2 2000/1/12 00:00:01;
# expire 2 2000/1/12 00:00:01;
#}
send host-name "thinkpad"; # added by NetworkManageroption rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
option ms-classless-static-routes code 249 = array of unsigned integer 8;
option wpad code 252 = string;request; # override dhclient defaults
also request subnet-mask;
also request broadcast-address;
also request time-offset;
also request routers;
also request domain-name;
also request domain-name-servers;
also request domain-search;
also request host-name;
also request dhcp6.name-servers;
also request dhcp6.domain-search;
also request dhcp6.fqdn;
also request dhcp6.sntp-servers;
also request netbios-name-servers;
also request netbios-scope;
also request interface-mtu;
also request rfc3442-classless-static-routes;
also request ntp-servers;
also request ms-classless-static-routes;
also request static-routes;
also request wpad;
Any idea what needs to be changed in order to achieve the desired behavior?
Last edited by GNUser (2019-05-19 12:17:26)
Offline
I don't use NetworkManager, sorry.
You could try ifupdown instead, any connections listed in /etc/network/interfaces will be ignored by NM so dhclient.conf will then be honoured:
https://wiki.debian.org/NetworkConfigur … _interface
EDIT: wireless instructions:
https://wiki.debian.org/WiFi/HowToUse#W … d_WPA2-PSK
Last edited by Head_on_a_Stick (2019-05-19 13:26:29)
Brianna Ghey — Rest In Power
Offline
Informative, thx. I happen to have a similar problem, but on the wired side of the router (my desktop always gets the same IP address, changing it always fails, now I know why. solution is simple: disconnect the ethernet cable on booting so the timer times out and a new IP address is obtained.)
Offline
I have a good-enough solution. It involves A) some changes in router (dhcp server side) and B) some changes in laptop (dhcp client side).
A. In router (assuming you, like me, are using dnsmasq as the dhcp server):
# pkill dnsmasq
# rm /var/lib/misc/dnsmasq.leases
# echo "dhcp-sequential-ip" >> /etc/dnsmasq.conf
# dnsmasq
B. In my Devuan ASCII laptop (which unfortunately uses network-manager, which runs dhclient when appropriate):
# vi /etc/init.d/network-manager
add this line under the 'start)' line: rm /var/lib/NetworkManager/dhclient*
# service network-manager restart
Now, even with the default dhclient settings in my Devuan laptop, DHCP is working in a way that seems intuitive. Namely:
1. router leases out the first available IP
2. router keeps track of leases and repeatedly gives a particular IP to a particular machine only during life of the lease
3. when network-manager starts or restarts on a client machine, dhclient cannot ask for an old IP because there is no record
Problem solved
P.S. Since I know Head_on_a_Stick likes both Devuan and OpenBSD (I'm brudan on daemonforums.org, by the way), for an OpenBSD laptop/desktop, part B is simply adding !rm /var/db/dhclient.leases.\$if to the top of your /etc/hostname.if file.
Last edited by GNUser (2019-05-20 00:43:20)
Offline