What's new

DHCP Multiple IP, One DNS Name

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Kevin K

Regular Contributor
I have a laptop configured to use either WiFi or Ethernet, but not both at once. I'd like to assign 192.168.1.10 to the WiFi, 192.168.1.11 to the Ethernet, and I'd like DNS to resolve "mylaptop" to whichever IP is currently active.

Yeah, I know that WINS can handle this for Windows computers, but not all of my devices speak WINS, so I really need them to be able to reach "mylaptop" via its currently active IP.

I *could* write a script which runs once a minute, pinging each IP, and then reconfiguring+restarting DNS if the active IP changes. Please tell me there's a simpler way!

How do I make DNS resolve to different IPs, depending upon which IP is active at the time?
 
This just natively works for me.

If you go to System Log>DHCP Leases and look for the hostname your laptop is presenting to your router.

Then you can ping <hostname>.<domainname> from any device in your LAN which is using the router as it's DNS server. Note that <domainname> is taken from LAN>DHCP Server>Domain Name

The router should handout your <domainname> as a Search Domain in it's DHCP Response's as well, so actually ping <hostname> in theory will be all you actually need.
 
I should say - DO NOT set a static IP assignment for the laptop in the DHCP server rules.
 
Don't assign any addresses to either of the laptop interfaces.....let DHCP handle it. Then, make a
/jffs/configs/dnsmasq.conf.add with the following line
Code:
dhcp-host=xx:xx:xx:xx:xx:xx,yy:yy:yy:yy:yy:yy,laptop_name
where xx:xx:xx:xx:xx:xx is the mac of the ethernet adapter and
yy:yy:yy:yy:yy:yy is the mac of the wireless adapter

Warning.....don't let both interfaces be active at the same time. Bad things happen if two connections have the same host name.
 
@JDB I think you've missed to point of his question.:rolleyes: Have another look.:)

@Kevin K I think you're over thinking this problem. You don't need to do anything on the router. Don't set DHCP reservations for the laptop, just let DHCP do it's thing. Then just make sure that both interfaces on the laptop have "Register this connections's addresses in DNS" set in the adapter properties (which is the default).

Here is the nslookup output of me switching my laptop from wireless to wired.
Code:
C:\Users\Colin>nslookup len
Server:  router.asus.com
Address:  192.168.1.1

Name:    len.home.lan
Address:  192.168.1.116


C:\Users\Colin>nslookup len
Server:  router.asus.com
Address:  192.168.1.1

Name:    len.home.lan
Address:  192.168.1.58
 
DUH...@ColinTaylor is right.....I use the conf.add above to also rename the weird names provided by some clients (like android).
 
@JDB I think you've missed to point of his question.:rolleyes: Have another look.:)

No no, I understood perfectly well.

Told the OP not to set anything special and just let DHCP do its thing whilst offering advice on how to find the hostname which will work in the local LAN.
Maybe you should look again at my reply :)



Sent from my iPhone using Tapatalk
 
I'd like to assign 192.168.1.10 to the WiFi, 192.168.1.11 to the Ethernet,
Is it a requirement to have fixed IP addresses rather than the dynamic ones handed out by DHCP? If so then in addition to what we have said above you will have to use a dhcp-host statement similar to what @john9527 said, but 2 entries:

dhcp-host=11:22:33:44:55:66,192.168.1.10
dhcp-host=77:88:99:aa:bb:cc,192.168.1.11
 
Thank you ColinTaylor. Yes, I really do want to assign a fixed IP address, because I separate my 'known' devices from my unknown devices by IP address range. When someone buys a new device, having it show up in the dynamic DHCP pool makes it easy for me to identify it.

I don't think I quite managed to combine the instructions properly. Here's what I came up with when I added ColinTaylor's to the content above.

dhcp-host=11:22:33:44:55:66,77:88:99:aa:bb:cc,laptop_name
dhcp-host=11:22:33:44:55:66,192.168.1.10
dhcp-host=77:88:99:aa:bb:cc,192.168.1.11

Of course, I used the real MAC addresses. It assigned laptop_name an address from the dynamic pool, rather than .10 or .11.
 
Last edited:
Most of these went over my head. I currently do this but I just assign fixed ip addresses to each mac address and then update that in my host file. I update the host file because I use vpn and log into my systems remotely.
Ahhh no, each entry has a different name i.e. laptop eth0, laptop wlan0 so they dont have same name. Sorry op. I must have missed my meds.
I will need to google dnsmasq.conf, dhcp-host statement and WINS and find out if they could solve my issue.
 
Thank you ColinTaylor. Yes, I really do want to assign a fixed IP address, because I separate my 'known' devices from my unknown devices by IP address range. When someone buys a new device, having it show up in the dynamic DHCP pool makes it easy for me to identify it.

I don't think I quite managed to combine the instructions properly. Here's what I came up with when I added ColinTaylor's to the content above.

dhcp-host=11:22:33:44:55:66,77:88:99:aa:bb:cc,laptop_name
dhcp-host=11:22:33:44:55:66,192.168.1.10
dhcp-host=77:88:99:aa:bb:cc,192.168.1.11

Of course, I used the real MAC addresses. It assigned laptop_name an address from the dynamic pool, rather than .10 or .11.


Try this:
dhcp-host=11:22:33:44:55:66,192.168.1.10,laptop_name
dhcp-host=77:88:99:aa:bb:cc,192.168.1.11,laptop_name


Sent from my iPhone using Tapatalk
 
Or even better, from the man page;
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.

http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

This way you only have 1 IP to deal with. Not sure if you want to keep separate IP's though?


Sent from my iPhone using Tapatalk
 
dhcp-host=11:22:33:44:55:66,192.168.1.10,laptop_name
dhcp-host=77:88:99:aa:bb:cc,192.168.1.11,laptop_name

This successfully makes both NICs have the DNS name laptop_name, but neither of them gets the specified IP address. Both pull from the dynamic pool.

Whoops! I failed to set "Enable JFFS custom scripts and configs". No wonder it has no effect.

... and with the scripts enabled the above syntax works just fine. Thanks for the assist.
 
Last edited:
Try this:
dhcp-host=11:22:33:44:55:66,192.168.1.10,laptop_name
dhcp-host=77:88:99:aa:bb:cc,192.168.1.11,laptop_name
Yes this works :) I've just tested it.

I thought there might be a problem with DNS returning both IP addresses when the name was queried (which would cause problems). But happily it's clever enough to only return the IP address for the most recently connected MAC address (even when both network interfaces are connected simultaneously :eek:).

But as we said earlier you could just have:

dhcp-host=11:22:33:44:55:66,192.168.1.10
dhcp-host=77:88:99:aa:bb:cc,192.168.1.11

because the client will register its name in DNS anyway.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top