You are not logged in.

#1 2017-06-29 05:15:28

jancici
Member
From: svk
Registered: 2011-12-04
Posts: 192

dnsmasq :: not using configured address

My network printer called "tlaciaren" stop to work.  I did find out that it get different IP when switch on and all PC on network knows printer as static IP.

1) checking leases

cat /var/lib/misc/dnsmasq.leases                                                                                  :(
1498713502 88:88:88:88:87:88 192.168.42.136 jarvis ff:4c:11:26:3c:00:02:00:00:ab:11:7d:4e:0b:4a:95:63:d9:68
1498713610 68:c4:4d:ab:cf:df 192.168.43.148 android-74d9f9053e4499b8 01:68:c4:4d:ab:cf:df
1498713539 68:c4:4d:ab:b5:45 192.168.43.108 android-1e6ad9f43bbc64f3 01:68:c4:4d:ab:b5:45
1498714043 18:a6:f7:1d:61:dd 192.168.43.66 pizero1 01:18:a6:f7:1d:61:dd

2) what happen during switch on printer

journalctl -f
-- Logs begin at Thu 2016-12-15 10:59:17 CET. --
Jun 29 07:02:32 skriatok systemd[21240]: Listening on GnuPG cryptographic agent and passphrase cache (access for web browsers).
Jun 29 07:02:32 skriatok systemd[21240]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Jun 29 07:02:32 skriatok systemd[21240]: Listening on GnuPG cryptographic agent and passphrase cache.
Jun 29 07:02:32 skriatok systemd[21240]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Jun 29 07:02:32 skriatok systemd[21240]: Listening on D-Bus User Message Bus Socket.
Jun 29 07:02:32 skriatok systemd[21240]: Reached target Sockets.
Jun 29 07:02:32 skriatok systemd[21240]: Reached target Basic System.
Jun 29 07:02:32 skriatok systemd[21240]: Reached target Default.
Jun 29 07:02:32 skriatok systemd[21240]: Startup finished in 38ms.
Jun 29 07:02:32 skriatok systemd[1]: Started User Manager for UID 1000.
Jun 29 07:03:32 skriatok dnsmasq-dhcp[654]: not using configured address 192.168.42.5 because it is in use by another host

3) check leases again

1498716215 00:15:99:3c:20:60 192.168.42.112 tlaciaren 01:00:15:99:3c:20:60
1498714399 88:88:88:88:87:88 192.168.42.136 jarvis ff:4c:11:26:3c:00:02:00:00:ab:11:7d:4e:0b:4a:95:63:d9:68
1498714512 68:c4:4d:ab:cf:df 192.168.43.148 android-74d9f9053e4499b8 01:68:c4:4d:ab:cf:df
1498714443 68:c4:4d:ab:b5:45 192.168.43.108 android-1e6ad9f43bbc64f3 01:68:c4:4d:ab:b5:45
1498714043 18:a6:f7:1d:61:dd 192.168.43.66 pizero1 01:18:a6:f7:1d:61:dd

here is part of my config:
my router has 3NETs, one for internet access and two for local network

dhcp-range=192.168.42.50,192.168.42.150,30m
dhcp-range=192.168.43.50,192.168.43.150,30m
dhcp-host=00:15:99:3c:20:60,tlaciaren,192.168.42.5,1h
dhcp-option=42,0.0.0.0

thank you for any help / tip how to solve this

Last edited by jancici (2017-06-29 05:15:57)

Offline

#2 2017-06-29 06:57:08

severach
Member
Registered: 2015-05-23
Posts: 192

Re: dnsmasq :: not using configured address

You'll do a lot better by filtering the output. Whatever GPG is doing is of no interest to us.

journalctl -r _SYSTEMD_UNIT=dnsmasq.service

Your first job is to ping the host that is claimed to be in use. If it responds, find the MAC and the product name (sudo nmap -sn 192.168.42.5) and neutralize it.

If nothing responds then I'd guess that that your printer broke and you replaced it with the same model. The new unit isn't given the old address because the old address is still leased out to the recycle unit. Your log does not show the MAC address of the current printer. Compare the MAC address that requested to the one that is leased out. I'm expecting them to be different.

Whichever, it is easy to fix.

The poor way to fix this is to stop dnsmasq, delete all or just the bad lease, then start dnsmasq.

The good way is to specify multiple MAC addresses until the new printer gets assigned.

% man dnsmasq
       -G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
...
              As  a  special  case,  in  DHCPv4,  it  is  possible  to  include  more  than  one  hardware  address. eg: --dhcp-
              host=11:22:33:44:55:66,12:34:56:78:90:12,192.168.0.2 This allows an IP address  to  be  associated  with  multiple
              hardware  addresses,  and  gives  dnsmasq permission to abandon a DHCP lease to one of the hardware addresses when
              another one asks for a lease. Beware that this is a dangerous thing to do, it will only work reliably if only  one
              of  the  hardware  addresses  is  active  at  any time and there is no way for dnsmasq to enforce this. It is, for
              instance, useful to allocate a stable IP address to a laptop which has both wired and wireless interfaces.

It also works for equipment change. Add the new MAC, restart dnsmasq, get the new IP assigned, remove the old MAC, then restart dnsmasq. This is safe to do on a production system.

This solution is why I had to stop using the cheesy DHCP implementation in routers. They neither show me what the problem is nor do they offer a way to fix it.

Last edited by severach (2017-06-29 06:59:53)

Offline

#3 2017-07-03 06:45:13

jancici
Member
From: svk
Registered: 2011-12-04
Posts: 192

Re: dnsmasq :: not using configured address

MAC address is same:

grep tlaciaren /etc/dnsmasq.conf 
dhcp-host=00:15:99:3c:20:60,tlaciaren,192.168.42.5,1h
sudo nmap -sn tlaciaren   

Starting Nmap 7.50 ( https://nmap.org ) at 2017-07-03 08:31 CEST
Nmap scan report for tlaciaren (192.168.42.112)
Host is up (0.00031s latency).
rDNS record for 192.168.42.112: tlaciaren.doma.sorob.me
MAC Address: 00:15:99:3C:20:60 (Samsung Electronics)
Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds

everytime I switch on printer DNSMASQ is not able to get to printer configured IP

sudo nmap -sn 192.168.42.5                                                                                                    :(

Starting Nmap 7.50 ( https://nmap.org ) at 2017-07-03 08:33 CEST
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 0.49 seconds

it is very strange, it was working nicely.
now I have to switch off printer, stop dnsmasq, delete leases file and start it again and switch on printer.

Offline

#4 2017-07-06 03:37:26

jancici
Member
From: svk
Registered: 2011-12-04
Posts: 192

Re: dnsmasq :: not using configured address

I did change lease time to 5minute for printer

grep tlaci /etc/dnsmasq.conf 
dhcp-host=00:15:99:3c:20:60,tlaciaren,192.168.42.5,5m

it is trick, after printer is switch on and it get wrong address because configured is in used that after 5minutes it ask to renew and then it get configured one.

before printer is switch on there is not machine with configured ip on network

sudo nmap -sn 192.168.42.5
[sudo] password for jano: 

Starting Nmap 7.50 ( https://nmap.org ) at 2017-07-06 05:34 CEST
Note: Host seems down. If it is really up, but blocking our ping probes, try -Pn
Nmap done: 1 IP address (0 hosts up) scanned in 0.50 seconds

and not item in leases

cat /var/lib/misc/dnsmasq.leases     
1499313259 88:88:88:88:87:88 192.168.42.136 jarvis ff:4c:11:26:3c:00:02:00:00:ab:11:7d:4e:0b:4a:95:63:d9:68
1499313290 68:c4:4d:ab:b5:45 192.168.43.104 android-1e6ad9f43bbc64f3 01:68:c4:4d:ab:b5:45
1499313129 68:c4:4d:ab:cf:df 192.168.43.144 android-74d9f9053e4499b8 01:68:c4:4d:ab:cf:df
1499312982 18:a6:f7:1d:61:dd 192.168.43.66 pizero1 01:18:a6:f7:1d:61:dd

any help | possible problem ?
thank you

Offline

#5 2017-07-08 20:41:29

duanev
Member
Registered: 2012-02-26
Posts: 14

Re: dnsmasq :: not using configured address

dnsmasq-dhcp[654]: not using configured address 192.168.42.5 because it is in use by another host

This error seems to appear in dnsmasq (my version is 2.77) when the dhcp-host option is used in dnsmasq.conf and there is not yet an entry in the leases cache file for the host (/var/lib/misc/dnsmasq.leases for me).  dnsmasq gives out a different ip (I assume depending on the presence dhcp-range) the first time, and then logs this "wrong" entry in leases.

Using a lease timeout in the dhcp-host option appears to let dnsmasq hand out the correct ip after the timeout cycles.  If you are impatient, kill dnsmasq, unplug the network cable, restart dnsmasq, reconnect, and dnsmasq appears to also get it right.

Offline

Board footer

Powered by FluxBB