Static Leases - one IP but two MAC's wifi+LAN on one client

Hi.
I tried configuring static leases in etc/config/dhcp for my client – ​​a laptop with two cards – a LAN RJ45 and a WiFi card. Both cards have different MAC addresses, so I added an entry in /etc/config/dhcp, but when I connect via WiFi and then connect an RJ45 cable, it doesn't receive a LAN address; it keeps WiFi. If I first delete /tmp/dhcp.leases and restart dnsmasq, and then connect via cable, I get the static IP in the configuration, but when I enable WiFi, I get a completely different IP on WiFi address.
Is there a way to work around this problem? Do I need to have different IPs for the LAN card and the WiFi card?

config host
        option name 'Lenovo'
        option ip '192.168.1.7'
        option leasetime 'infinite'
        list mac '98:33:8B:AA:CD:AA'
        list mac 'AA:EE:BB:CC:DD:DD'

Or should I made it:

config host
        option name 'Lenovo'
        option ip '192.168.1.7'
        option leasetime 'infinite'
        list mac '98:33:8B:AA:CD:AA'

config host
        option name 'Lenovo'
        option ip '192.168.1.8'
        option leasetime 'infinite'
        list mac 'AA:EE:BB:CC:DD:DD'


OpenWRT 24.10.5

The latter example is what you should use. Each MAC should have its own IP address mapping.

1 Like

The best way to do this is to make sure the laptop has a unique hostname on your network then have one entry which links name and ip but no MAC defined. The DHCP server will key on the hostname and issue the same IP address no matter what networking MAC is being used by the device.

Infinite leasetime is a problem since the first MAC to connect will stay in the table forever, making it impossible to reissue the IP to a different MAC later. When the network is changing you need short lease times.

2 Likes

OK. Thank you both for the clarification.

I think I'll stick with two different IP addresses.