I have several systems that contain both a WiFi card and an Ethernet card. The intent is to use only one of them, ethernet where possible, of course. But I do want to give both a static entry in OpenWRT.
In the DNS and DHCP configuration examples it states that I would have to set space-separated MAC-entries in
uci set dhcp.host.mac. This appears to work, although Luci doesn't like it.
It also states: "Add multiple host entries, one per MAC address or DUID, if you plan connect more than one interface simultaneously, otherwise it's unreliable."
I figured why not use the second option? Create separate entries. This would have the added benefit of being able to give a different IP to the two interfaces so I can easily recognize by the IP which network interface is active at the time.
Problem is that when I do that, I also get two DNS entries for that host, so half the time I can't connect because it picks the wrong one.
What is the correct way to configure for this scenario?
Ideally you shouldn't connect 2 interfaces to the same network if they are not bridged.
If you do though, change the metric so that only one will be active and you'll know which one.
That would sort of defeat the purpose, wouldn't it? To name an example, I have a very annoying workstation that uses ethernet usually, but for some mysterious reason it completely removes the ethernet card when it has gone to sleep, which then won't come back on until I reboot. At which point it would use wireless instead.
If I do a DNS query for that workstation, would it not always return the result with the metric that has the highest priority (not sure if that means highest or lowest value until I look it up)? So if I give ethernet the highest priority and it goes down, wouldn't I always get a time-out?
I really like the idea of using separate subnets (or at the very least different ranges within the same subnet) to easily identify which interface I'm using. Especially with Windows 10 nowadays transparently connecting to both simultaneously. A feature which I do like, since they finally figured out how to prioritize the ethernet without user intervention.
The lower metric/ higher preference applies to which interface will be used when the routing table has the same entry for more than one interface.
If one interface is not there, then traffic will use the other interface regardless of the metric.
What you have is a hardware issue and trying to make a workaround with non standard configs in the dhcp server might cause more issues.
Regarding the name that the workstation has, if you let dhcp server define it, it will be the first IP which registered to the server. You can always make a static assignment and disregard the dhcp entry.
The problem here is DNS resolution. DNS tends to use round-robin. So if I create two host records with the same name to enter into the DNS zone, there is always a 50% chance that any peer will receive the inactive interface and fail to connect.
I am used to the Windows way of doing things where the DHCP gives an IP and then either the client registers itself into the DNS or the DHCP does it for them. That way, the A-record is (usually) valid for whichever IP is active at that point.
But if that is a non-standard way of doing things, what is the standard way?
The dnsmasq man page recommends against adding multiple mac-addresses to a host record. The OpenWRT page seems to agree as it indicates this could lead to issues and one should make separate host entries instead. Which then in turn can not have the same IP as that leads to other issues, but can have the same name. But if I do that, we come full circle and we're back to a 50% chance it won't work.
So then what is the standard config for a laptop with both wired and wireless interfaces if you want its name to resolve to the correct interface by OpenWRT 100% of the time? Do I leave the name fields out of the static lease entries and dnsmasq will accept whatever name the client passes?
The standard is that if you have 2 interfaces in the same network, you bridge them. And you also run STP to avoid loops.
Other than that, you can create an A record laptop-eth.lan and laptop-wifi.lan pointing to the different IP addresses that the dhcp will allocate to them and you can tell which one is which.
I used different hostnames for the different interfaces during my previous install, but that gets very annoying. Plus, it wouldn't allow me to use a single label/name to get to the device regardless of which interface is up at that point.
But it would seem there simply is no elegant way to do this then.