Discussion:
[Dnsmasq-discuss] DHCP for pairs MAC:IP only
v***@iptrans.net
2018-01-25 15:55:18 UTC
Permalink
Good day

I have a DHCP-router based on dnsmasq with interface eth2 and networks
192.168.100.1/24 192.168.100.2.1/24 10.0.0.1/27 on this interface. There
are computers-dhcp-clients on this network which have to get IP based on
their MAC-addresses. And if file /etc/dnsmasq.conf doesn't contain line
with corresponding MAC (option dhcp-host) then this computer doesn't get
an IP via my DHCP-router.

But.

In /etc/dnsmasq.conf:

# Uncomment this to enable the integrated DHCP server, you need
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
# dhcp-range=192.168.0.50,192.168.0.150,12h

And if I uncomment "# dhcp-range" then I'll have computer-dhcp-client
which will get a ip address without corresponding MAC in
/etc/dnsmasq.conf.
john doe
2018-01-25 16:42:42 UTC
Permalink
Post by v***@iptrans.net
Good day
I have a DHCP-router based on dnsmasq with interface eth2 and networks
192.168.100.1/24 192.168.100.2.1/24 10.0.0.1/27 on this interface. There
are computers-dhcp-clients on this network which have to get IP based on
their MAC-addresses. And if file /etc/dnsmasq.conf doesn't contain line
with corresponding MAC (option dhcp-host) then this computer doesn't get
an IP via my DHCP-router.
But.
# Uncomment this to enable the integrated DHCP server, you need
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
# dhcp-range=192.168.0.50,192.168.0.150,12h
And if I uncomment "# dhcp-range" then I'll have computer-dhcp-client
which will get a ip address without corresponding MAC in /etc/dnsmasq.conf.
If I understand you correctly you want only hosts that have a matching
mac address to be given an address for a specific subnet (192.168.100.0/24).
For that you can use the 'static' keyword:

dhcp-range=192.168.100.2,static,12h

In case it is not what you want dhcp-host should have the form:

dhcp-range=192.168.100.2,192.168.100.253,12h
dhcp-host=ab:cd:ef:gh:ij:kl,fix-ip-to-be-given-to-host
--
John Doe
v***@iptrans.net
2018-01-25 17:57:20 UTC
Permalink
Post by john doe
Post by v***@iptrans.net
Good day
I have a DHCP-router based on dnsmasq with interface eth2 and networks
192.168.100.1/24 192.168.102.1/24 10.0.0.1/27 on this interface. There
are computers-dhcp-clients on this network which have to get IP based
on their MAC-addresses. And if file /etc/dnsmasq.conf doesn't contain
line with corresponding MAC (option dhcp-host) then this computer
doesn't get an IP via my DHCP-router.
But.
# Uncomment this to enable the integrated DHCP server, you need
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
# dhcp-range=192.168.0.50,192.168.0.150,12h
And if I uncomment "# dhcp-range" then I'll have computer-dhcp-client
which will get a ip address without corresponding MAC in
/etc/dnsmasq.conf.
If I understand you correctly you want only hosts that have a matching
mac address to be given an address for a specific subnet
(192.168.100.0/24).
dhcp-range=192.168.100.2,static,12h
dhcp-range=192.168.100.2,192.168.100.253,12h
dhcp-host=ab:cd:ef:gh:ij:kl,fix-ip-to-be-given-to-host
Thanks.

:) My man page for dnsmasq doesn't have a information about optional
static mode for dhcp-range like on link
http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html:

"The optional <mode> keyword may be static which tells dnsmasq to enable
DHCP for the network specified, but not to dynamically allocate IP
addresses: only hosts which have static addresses given via dhcp-host or
from /etc/ethers will be served. A static-only subnet with address all
zeros may be used as a "catch-all" address to enable replies to all
Information-request packets on a subnet which is provided with stateless
DHCPv6, ie --dhcp-range=::,static"

For example configuration:

interface=eth2
dhcp-range=192.168.100.0,static
dhcp-range=192.168.102.0,static
dhcp-range=10.0.0.0,static
dhcp-host=ab:cd:ef:gh:ij:kl,192.168.102.10

With this configuration pc with mac "ab:cd:ef:gh:ij:kl" get
192.168.102.10 and no other ip.
Аnd any other pc with a different mac will not receive any ip from my
dhcp-server.
john doe
2018-01-25 18:31:08 UTC
Permalink
Post by v***@iptrans.net
Post by john doe
Post by v***@iptrans.net
Good day
I have a DHCP-router based on dnsmasq with interface eth2 and
networks 192.168.100.1/24 192.168.102.1/24 10.0.0.1/27 on this
interface. There are computers-dhcp-clients on this network which
have to get IP based on their MAC-addresses. And if file
/etc/dnsmasq.conf doesn't contain line with corresponding MAC (option
dhcp-host) then this computer doesn't get an IP via my DHCP-router.
But.
# Uncomment this to enable the integrated DHCP server, you need
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
# dhcp-range=192.168.0.50,192.168.0.150,12h
And if I uncomment "# dhcp-range" then I'll have computer-dhcp-client
which will get a ip address without corresponding MAC in
/etc/dnsmasq.conf.
If I understand you correctly you want only hosts that have a matching
mac address to be given an address for a specific subnet
(192.168.100.0/24).
dhcp-range=192.168.100.2,static,12h
dhcp-range=192.168.100.2,192.168.100.253,12h
dhcp-host=ab:cd:ef:gh:ij:kl,fix-ip-to-be-given-to-host
Thanks.
:) My man page for dnsmasq doesn't have a information about optional
static mode for dhcp-range like on link
"The optional <mode> keyword may be static which tells dnsmasq to enable
DHCP for the network specified, but not to dynamically allocate IP
addresses: only hosts which have static addresses given via dhcp-host or
from /etc/ethers will be served. A static-only subnet with address all
zeros may be used as a "catch-all" address to enable replies to all
Information-request packets on a subnet which is provided with stateless
DHCPv6, ie --dhcp-range=::,static"
interface=eth2
dhcp-range=192.168.100.0,static
dhcp-range=192.168.102.0,static
dhcp-range=10.0.0.0,static
dhcp-host=ab:cd:ef:gh:ij:kl,192.168.102.10
With this configuration pc with mac "ab:cd:ef:gh:ij:kl" get
192.168.102.10 and no other ip.
Аnd any other pc with a different mac will not receive any ip from my
dhcp-server.
If you want "fix" address and "non-fix" address on the same subnet
(192.168.100.0/24):


dhcp-range=192.168.100.100,192.168.100.150,12h
dhcp-host=ab:cd:ef:gh:ij:kl,192.168.100.90

The above line means that the host with the mac address
'ab:cd:ef:gh:ij:kl' will always get 192.168.100.90.
Any other hosts will get an ip addres from 192.168.100.100 to
192.168.100.150 (50 addresses available).

Normally you would use one subnet per interface:

interface=eth2
interface=eth3
dhcp-range=192.168.100.100,192.168.100.150,12h
dhcp-range=192.168.101.100,192.168.101.150,12h

The subnet to be used is the one set on the interface.
--
John Doe
Loading...