Re: [Dnsmasq-discuss] Static leases issues

2020-06-08 Thread john doe

On 6/8/2020 6:18 PM, Bruno BEAUFILS wrote:

Hello everyone,

I have got a static leases issue with dnsmasq 2.80-1 installed as
Debian Buster package.

I search the man page and the mailing list archives without any
success. Thus I try here.

Here is short summary of what I have.

I am on a simple LAN with a screenless host running dnsmasq. It is the
only, and thus main, DHCP server on the network.

I use the dhcp-authoritative option in dnsmasq configuration.

It offers a dhcp-range looking like that...

 dhcp-range=192.168.0.200,192.168.0.250,12h

...and a bunch of static lease looking like something like that

 dhcp-host=xx:xx:xx:xx:xx:xx,id:*,192.168.0.2,somename

I want to use a new USB-ethernet adpator on a new laptop.

On the first connection the host get a IP from the open range
(192.168.0.203) as it is visible in the logs:

 Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPDISCOVER(eth1) 
12:34:56:78:9a:bc
 Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPOFFER(eth1) 192.168.0.203 
12:34:56:78:9a:bc
 Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPDISCOVER(eth1) 
12:34:56:78:9a:bc
 Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPOFFER(eth1) 192.168.0.203 
12:34:56:78:9a:bc
 Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPREQUEST(eth1) 192.168.0.203 
12:34:56:78:9a:bc
 Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPACK(eth1) 192.168.0.203 
12:34:56:78:9a:bc mechra

After the first connection I am able to log on the server and add a
dhcp-host specific to that host. For that I did the following things
in order :

1. stop the dnsmasq server

2. remove the leases file

3. modify the dnsmasq configuration in order to add the dhcp-host
option

 dhcp-host=00:23:4d:df:a1:d1,id:*,192.168.0.15,somefancyname,24h

4. start the dnsmasq server

After that I unplug the adaptor from the laptop and replug it in order
for it to get the new IP from the static lease. Unfortunately I always
get the same "old" adress (192.168.0.203), as the log shows (because
the client asked it):

 juin  7 18:05:23 b3 dnsmasq-dhcp[29360]: DHCPREQUEST(eth1) 192.168.0.203 
12:34:56:78:9a:bc
 juin  7 18:05:23 b3 dnsmasq-dhcp[29360]: DHCPACK(eth1) 192.168.0.203 
12:34:56:78:9a:bc mechra

I thought the dnsmasq should have refused the client request of using
192.168.0.203 (through a DHCPNAK for instance) and sent it a new
OFFER with the correct static (192.168.0.15).

Did I miss something (aka this is normal behavior but I misconfigured
the whole stuff certainly because I did not understand the
documentation well enough) or am I struggling with some kind of bug?

Just in case it matters: all host used in the description are running Debian.



Try clearing the lease for the host in question:

$ systemctl stop dnsmasq
Remove the file altogether or remove the desired lease in the lease file:.
Lease file path: '/var/lib/misc/dnsmasq.leases'
$ systemctl start dnsmasq


IN plain English, you need to clear the lease or you need to wait for
the lease to expire.

HTH.

--
John Doe

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


[Dnsmasq-discuss] Static leases issues

2020-06-08 Thread Bruno BEAUFILS
Hello everyone,

I have got a static leases issue with dnsmasq 2.80-1 installed as
Debian Buster package.

I search the man page and the mailing list archives without any
success. Thus I try here.

Here is short summary of what I have.

I am on a simple LAN with a screenless host running dnsmasq. It is the
only, and thus main, DHCP server on the network.

I use the dhcp-authoritative option in dnsmasq configuration.

It offers a dhcp-range looking like that...

dhcp-range=192.168.0.200,192.168.0.250,12h

...and a bunch of static lease looking like something like that 

dhcp-host=xx:xx:xx:xx:xx:xx,id:*,192.168.0.2,somename

I want to use a new USB-ethernet adpator on a new laptop.

On the first connection the host get a IP from the open range
(192.168.0.203) as it is visible in the logs:

Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPDISCOVER(eth1) 12:34:56:78:9a:bc
Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPOFFER(eth1) 192.168.0.203 
12:34:56:78:9a:bc
Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPDISCOVER(eth1) 12:34:56:78:9a:bc
Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPOFFER(eth1) 192.168.0.203 
12:34:56:78:9a:bc
Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPREQUEST(eth1) 192.168.0.203 
12:34:56:78:9a:bc
Jun  7 17:38:29 b3 dnsmasq-dhcp[12907]: DHCPACK(eth1) 192.168.0.203 
12:34:56:78:9a:bc mechra

After the first connection I am able to log on the server and add a
dhcp-host specific to that host. For that I did the following things
in order :

1. stop the dnsmasq server

2. remove the leases file

3. modify the dnsmasq configuration in order to add the dhcp-host
   option

dhcp-host=00:23:4d:df:a1:d1,id:*,192.168.0.15,somefancyname,24h

4. start the dnsmasq server

After that I unplug the adaptor from the laptop and replug it in order
for it to get the new IP from the static lease. Unfortunately I always
get the same "old" adress (192.168.0.203), as the log shows (because
the client asked it):

juin  7 18:05:23 b3 dnsmasq-dhcp[29360]: DHCPREQUEST(eth1) 192.168.0.203 
12:34:56:78:9a:bc
juin  7 18:05:23 b3 dnsmasq-dhcp[29360]: DHCPACK(eth1) 192.168.0.203 
12:34:56:78:9a:bc mechra

I thought the dnsmasq should have refused the client request of using
192.168.0.203 (through a DHCPNAK for instance) and sent it a new
OFFER with the correct static (192.168.0.15).

Did I miss something (aka this is normal behavior but I misconfigured
the whole stuff certainly because I did not understand the
documentation well enough) or am I struggling with some kind of bug?

Just in case it matters: all host used in the description are running Debian.

-- 
Bruno BEAUFILS


signature.asc
Description: PGP signature
___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


Re: [Dnsmasq-discuss] read /etc/hosts if DNS disabled

2020-06-08 Thread Matus UHLAR - fantomas

Hello,


> > > On Fri, May 15, 2020 at 07:53:50PM +0200, Matus UHLAR - fantomas wrote:
> > > > I have problems configuring static DHCP using /etc/hosts and 
/etc/ethers.
> > > > It seems that dnsmasq is ignoring /etc/hosts when dns server is disabled
> > > > via "-p 0" option.
> > > >
> > > > Can anyone confirm?
> > > > If I'm right, is this bug or a feature?
> >
> > On 21.05.20 15:03, Geert Stappers wrote:
> > > Advice: Describe "the problem" better.



> On Thu, May 21, 2020 at 03:35:24PM +0200, Matus UHLAR - fantomas wrote:
> > the problem is that DHCP clients listed in /etc/ethers will not be given IP
> > addreses specified in /etc/hosts when dnsmasq does not run DNS service
> > (-p 0), because /etc/hosts is not read in that case.
> >
> > the workaround is to run DNS at different port (e.g.  -p 54), so dnsmasq
> > reads /etc/hosts and provides IPS configured there do clients from
> > /etc/ethers, but I believe /etc/hosts should be read even without DNS,
> > unless explicitly disabled.

On 21.05.20 18:33, Geert Stappers wrote:
> Acknowledge on version 2 of "problem description".
>
> I partially understand what the expectations are.



On Thu, May 21, 2020 at 08:42:07PM +0200, Matus UHLAR - fantomas wrote:

a litle background:

I used dnsmasq on openwrt router using /etc/ethers for machine<>ethernet
address conversion and /etc/hosts for host to IP conversion (for both DHCP
and DNS).

I bought new router with turris (openwrt clone) which uses knot-resolver
(which uses /etc/hosts for local DNS) and runs dnsmasq only as DHCP server

The problem is that while in this scenario dnsmasq does use the ethers table
(I can see that in reservations info), but it does not use hosts table to
assign proper IP addresses for those hosts.

as a workaround I set dnsmasq to run DNS on another port (I'm thinking on
disabling knot-resolvet) so while the DNS is not used, correct IP addresses
are assigned.

I'd like dnsmasq to read /etc/hosts table for DHCP reservations even when
DNS is not used.

... I know I can work around reservations, but I find /etc/ethers and
/etc/hosts good standards to use


On 06.06.20 15:52, Geert Stappers wrote:

For what it worth, dnsmasq.conf.example has

# If this line is uncommented, dnsmasq will read /etc/ethers and act
# on the ethernet-address/IP pairs found there just as if they had
# been given as --dhcp-host options. Useful if you keep
# MAC-address/host mappings there for other purposes.
#read-ethers


I suggest to play with a dnsmasq.conf that has

# dnsmasq should read /etc/ethers and act on the ethernet-address/IP pairs
# found there just as if they had been given as --dhcp-host options.
# Used for keeping MAC-address/host mappings there for other purposes.
read-ethers



I do have "read-ethers" set in config file, and /etc/ethers is loaded (host
names seen in logs are those from ethers, not client provided names).

Unfortunately, when "-p 0" option is used (so dnsmasq does not provide DNS
service), the /etc/hosts seems not to be read, so hosts listed in
/etc/ethers will get random IP addresses from dynamic pool assigned, instead
of static addresses listed in /etc/hosts.

I was able to work around this by using random port (53 is used by different
software on the router), but I was wondering if my observation is correct,
and if so, if it is known, expected/wanted behaviour.

I am not a programmer (although I do understand C a bit), so trying to RTFS
didn't help me much. I'll try again.

P.S.
Thanks for the patience. 
Of course you don't owe me anything - please accept my apology if any of my
mails indicated that. 


--
Matus UHLAR - fantomas, uh...@fantomas.sk ; http://www.fantomas.sk/
Warning: I wish NOT to receive e-mail advertising to this address.
Varovanie: na tuto adresu chcem NEDOSTAVAT akukolvek reklamnu postu.
Windows found: (R)emove, (E)rase, (D)elete

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss