[Dnsmasq-discuss] Same IP for a range of MAC addresses?

Tom Metro tmetro+dnsmasq at gmail.com
Sat Apr 4 00:29:46 BST 2009


Stephen Lee wrote:
> I have a linux box running dnsmasq that needs to assign the
> same IP to whichever dhcp client it happens to be connected to.

Can you elaborate on your setup? It sounds rather unusual.


> Is it possible to for dnsmasq to assign the same IP to a range of MAC
> addresses? 

I think I ran across the answer to that in the FAQ recently (see below), 
but it sounds like you have to list each MAC address and I wonder if 
there is a better solution for your situation. Can you get the clients 
to issue a consistent ID or host name?

I thought maybe you could use dhcp-mac to map from MAC addresses to a 
network ID tag, but dhcp-host doesn't use network ID tag as a selector 
(instead it does the equivalent of a dhcp-mac to apply the tag for the 
benefit of other options). Which is logical, given that network ID tags 
are meant to apply to groups of machines, and dhcp-host is normally 
meant to apply to a single machine.

  -Tom

http://thekelleys.org.uk/dnsmasq/docs/FAQ

Q: My laptop has two network interfaces, a wired one and a wireless
    one. I never use both interfaces at the same time, and I'd like the
    same IP and configuration to be used irrespective of which
    interface is in use. How can I do that?

A: By default, the identity of a machine is determined by using the
    MAC address, which is associated with interface hardware. Once an
    IP is bound to the MAC address of one interface, it cannot be
    associated with another MAC address until after the DHCP lease
    expires. The solution to this is to use a client-id as the machine
    identity rather than the MAC address. If you arrange for the same
    client-id to sent when either interface is in use, the DHCP server
    will recognise the same machine, and use the same address. The
    method for setting the client-id varies with DHCP client software,
    dhcpcd uses the "-I" flag. Windows uses a registry setting,
    see http://www.jsiinc.com/SUBF/TIP2800/rh2845.htm
Addendum:
    From version 2.46, dnsmasq has a solution to this which doesn't
    involve setting client-IDs. It's possible to put more than one MAC
    address in a --dhcp-host configuration. This tells dnsmasq that it
    should use the specified IP for any of the specified MAC addresses,
    and furthermore it gives dnsmasq permission to sumarily abandon a
    lease to one of the MAC addresses if another one comes along. Note
    that this will work fine only as longer as only one interface is
    up at any time. There is no way for dnsmasq to enforce this
    constraint: if you configure multiple MAC addresses and violate
    this rule, bad things will happen.



-- 
Tom Metro
Venture Logic, Newton, MA, USA
"Enterprise solutions through open source."
Professional Profile: http://tmetro.venturelogic.com/



More information about the Dnsmasq-discuss mailing list