DNS confusion in my LAN

My home LAN has 3 linux machines, each multi-boot with other linux distros, as well as Macs, iPads etc. Mainly, I want to have ssh and samba connectivity between all my linux machines no matter which distros I have booted. I'm using my OpenWrt router as a DNS for the LAN so each machine looks to or DNS. I use DHCP on each OS but in OpenWrt > Network > Hostnames I gave each named machine a specific IP, so when that machine boots it has that specific address. Worked pretty well until recently. Some of my machines are wired, but a laptop is wifi. I have 4 distros on it. It seems like some of them want to use the IP of another (maybe previously booted) machine. Of course this screws up my smb/cifs mounting from another machine! I have fstab entries like //lapdog/home but #mount /media/lapdog fails with "entry not found." Some kern.log show "duplicate machine" entries. And the OpenWrt Overview page shows some laptop machines holding on to leases with those inet6 addresses even tho another distro is now open. Not sure how to fix this.

Probably easiest if you just create a set of DHCP reservations by MAC address, since that should be consistent across any/all OS's on a given host.


Just to clarify, do you want the different diestros on the same machine to share the same IP or have different IPs?

If you want them to share the same IP then do what @psherman said. That can be found at Network > DHCP and DNS > Static Leases.

If, on the other hand, you want the different diestros to have different IPs, and the host name isn't dying the trick, then maybe you can change the MAC addresses for the distros, and then give them static leases.

OK, what I HAD been doing was giving each distro (even on the same machine) a different IP and doing it via DHCP on the individual distro, but putting the desired IP in Openwrt's Network > Hostname's page. So @psherman is saying give all distros on say, the laptop, the same IP. OK if I do that and use DHCP (on the individual distro's), how do I adjust Openwrt to give them all the same IP?

On the other hand, if @Hegabo, I use static IP on all distro's on all machines, then I understand that would work, and I could keep using Openwrt > Network > Hostnames to name them. But I would rather not go thru the trouble of filling out static IP's on each distro.

Is there a third alternative, to somehow shorten (maybe eliminate) the length of the IP leases? So if I'm running distro mint on the laptop (and it get's a lease) then reboot and start running distro ubuntu it will get the IP named in Hostnames rather than getting bumped to another?

Network > DHCP and DNS > Static Leases > Add
provide a hostname, the system's MAC address, and the desired IP address. The other fields are optional -- you can leave those blank.

This will ensure that each computer (the hardware) always has the same IP address and hostname on the network. Unless you override the MAC address on the host itself (which would be unusual), the MAC address should always be the same regardless of the OS that is running on that system. The static lease simply says "I see a DHCP request coming from a computer with MAC address I've got in my table of static leases -- that means I will offer it this specific IP address."

The hostname will also be registered in the DNS tables on the router. Assuming that your clients use the router for DNS, you can type in hostname1.lan and it'll resolve to the right machine.

Yes I would suggest short lease times if clients are often being removed from the network. It is easily set on the OpenWrt DHCP server.

Other than forwarding ports to a machine running as an external server, there's usually not a need to have anything at a fixed or known IP address. Use DNS on your LAN and configure peer connections by name.

Don't go too short, though -- a lot of it depends on the size of your network and how many hosts are staying on your network all the time vs how many might be rotating on and off. A popular cafe, for example, might have 1 hour or less lease times to ensure that they don't exhaust their DHCP pool. But a small home network with devices that are frequently on the network (even if they leave for a while, like a phone) could have lease times in the range of a week or so without issue.

1 Like

Just so I'm sure on @psherman solution. I'd remove my entries from Network > Hostnames and put them instead on Network > DNS & DHCP > Static Leases? I looked there and am not certain how to set up the additions. Can I give laptop os1 the same IP as laptop os2 & os3 but keep the machine ID the same? Is that the idea? Also if os1 is booted and gains a "lease time" will that interfere if I reboot to os2? or not?

I like the idea of having the same IP for a machine regardless of which distro boots, but it will be different from what I'm doing now. So before I start, I want to know what I'm doing.

On a related note, I'm now setting my router IP as the primary DNS server for my LAN machines, but actual name recognition did not seem to work in all cases. For example to ping another machine, router or printer, ping would work, but name tab-completion did not. Same for ssh tab-completion. This annoyed me so I put a file in each machine's /etc/bash_completion.d/ named "ping_list" which followed a style I found for ping & ssh. Seems to work OK, but it's always seemed like a kludge, is there something I can do on Openwrt to solve this once w/o monkeying with each machine?

I wasn't talking about setting a static IP on the machine. Static Lease is the term used by OpenWrt for assigning a fixed IP by the DHCP Server based on the MAC address--so it's what @psherman was talking about; I was only telling you where to find it in OpenWrt and by what name.

1 Like

OK, I understand. I've started to apply this to the laptop. On Network > DCHP & DNS > Static Leases, I've given each OS, it's own hostname (the existing one) and now the same machine ID and same IP.

When mounting a share in the LAN, it is called by it's name (hostname) which has to be resolved in Openwrt. Just so I understand how DNS works there, if the lan machines know to look to the router IP for name resolution, does it go to the Static Leases page to find that? What about the Hostname's page, what does that do? Or am I confused?

edit: I left DUID, Lease Time and IPv6 blank as I'm not sure what's needed.

No -- each machine should have a hostname. Not each OS. If you have MachineA running Ubuntu, Debian, and Windows, they are all MachineA for the hostname. That is because the MAC address is a value that is programmed into the network hardware, so it is always the same no matter what OS is running.

There are other ways to do this, but the simplest is to have OpenWrt (assuming it is your main router) handle this for you. You can also use the IP address.

The main router in many home and small business networks is the default DNS server. It will look at its own tables to resolve the IP address that corresponds to a hostname/domain name on a network. If it doesn't find it in the table, it will look to the next DNS server up the chain (your ISP's DNS server or a public one of your choice), but for all of the devices in your own network, the router is going to be the DNS server that will 'know' your own network (the dns servers outside your network do not have any knowledge of your local hostnames).

The machines on your LAN will look to your router. Your router can have the hostnames stored in either location (although preferably not both). If you want to make sure that a machine always gets the same the IP address on your network, you use the static leases feature (which is what the DHCP server uses to allocate IP addresses, but the hostname is also used to populate the DNS records on your router).

Just leave them blank.

Not sure the @psherman solution is working...or maybe I'm not doing it right. Yes, I put the info in both places...soon my wife complained that I "broke the internet," so yes putting them is both places in NOT good. I'll have to play around with this a bit to see what works best for me.

Yes I understand about the machine's MAC address...and that it's unique to the device, but the machine itself doesn't need a name (at least one that means anything) does it? That's a bit confusing.

Understand, and I think that's how I'm using it. Each OS has as it's network setting as the primary DNS server, so it looks there first. I experimented by just using the Hostname's page and giving all OS's on the laptop the same IP, did reboots, and they seem to be playing nicely again. May not be the best way, maybe using the Static leases is better, but I'll play with it later. Thx for your good explanations. The way to do this is here, but for now I'll wait to test more before calling "solution." Thanks!

You should setting all of your hosts to use dhcp. It will obtain the address from the router automatically. That is the whole point of static leases.

Static Lease works by MAC address. The host name you put in doesn't have to correspond with the actual host name. It's for your info. For example, some of my hosts have both wired and wireless cards, and I connect them by this or that depending on the circumstances. So for the wired static Lease entry I call it pc-lan and for the wireless I call it pc-wifi, for example.

It's really much simpler than you think it's. You don't have to worry about DNS or adjusting anything on the hosts. All you need to do is to go to the static LEASE, select a device (MAC address), type an IP (and hit Enter), and give it a friendly name.

1 Like

OK, identifying things on the Hostname page works but I'm finding one cannot use the same IP for all OSs on a machine...at least doing it there. SSH and samba (cifs mounts) id'd in fstab do not work. Pinging the laptop gives the MAC address to identify it, not the IP. So I cannot do that. Either I want to go the DHCP & DNS > Static leases route, but don't have time to play with it now.

As far as name's identifying an OS, why not use it's hostname, as in /etc/hostname?

I have been doing that. All my hosts use dhcp. My quick attempt at switching to using the Static leases didn't go well. Will have to do it with more time/thought. thx

DHCP static lease will reserve an IP for a specific MAC address. That means, if LAPTOP boots Ubuntu/Windows/Android/WhateverOS for the same connection (wired or wireless, they have different mac addresses) will get the same address.
OpenWrt will also create a DNS entry for the hostname that you used when you created the static lease.

So in this example:

config host
        option name 'laptop'
        option dns '1'
        option mac '00:19:d6:zz:ee:4b'
        option ip ''

So if you ping laptop, address will be resolved and the packets will be sent to laptop.
The name here has nothing to do with the hostname you have assigned in /etc/hostname or in Windows on this laptop. Consider the first as network hostname and the second as device hostname if it is easier.
Samba, ping, ssh and any other network program will use the network hostname.
Booting different OS doesn't make any difference in terms of dhcp lease. DHCP client will send a dhcp discover packet and server will respond to that with an offer. Sure, this lease might still be active, although it shouldn't if the previous OS shut down gracefully and released the DHCP lease, but it doesn't matter as it is reserved for that specific host only.


An option is to leave the MAC address blank in the Static lease page and only include the hostname and Set the IP you desire for each host.

Then for each distro / OS instance give it a unique hostname.

When the distro boots it will request an IP for it hostname (client ID)

So you shouldn't be restricted by MAC address and your IPs can be managed on the router

1 Like

So are you saying that if you leave the MAC address out, the host name is actually matched against the OS host name? Because when there is a MAC address, I can put whatever hostname I like as the host name and the static lease still works.

Yes, the hostname is matched.

The hostname is used as a client ID or the client ID can be explicitly set, check your OS documentation.


You can see here that MAC is optional


Yeah, I see.

I tried it. With MAC address and unmatchable hostname, PC got an IP.

Also with a matchable hostname and no MAC address.

I wonder which would take precendence: hostname or MAC address, in case of a conflict (e.g. use the hostname of a machine and the MAC address of another), but I'm not going to check it.

So, as far as the OP is concerned, if they want same IP for all distros of one particular machine, then they can use the MAC address. Otherwise if they want different IPs for different distros, then: