[Solved] Static Lease Based on Hostname

I have a small network with some Wireless access points and mainly wifi clients. One of my clients' computer keeps changing his/her mac address. I don't know exactly why is this happening because there is no need to change mac address and whether it's intentionally or whatever. I assign a static IP to each client based on mac address but for that one client, I have already added 4 mac addresses to the mac list. I need static addresses to record internet usage, as how much internet data they have used.

His/her hostname on the other hand is same, which is the computer name that is received while connecting to router. Now I am wondering if it is possible to assign static IP with the help of hostname rather than the mac address. I have tried searching documentation and google but nothing so far.

Any help would be greatly appreciated. Thanks

Well I have Windows 10 but I dont see that option listed for me. But anyway it may be possible though in any case I would need a way to assign static IP through Hostname.

MAC address comes from the adapter, so it will be different for the host using wired vs. wireless or internal wireless vs. a USB radio.

Put a config host in /etc/config/dhcp with the hostname and ipaddr you want. In other words, dnsmasq can use either mac or hostname to identify a host.

config host
    option name 'the-hostname'
    option ipaddr '192.168.3.4'

In general I like to avoid static IPs and address everything by name.

1 Like

I tried your example from LUCI and it also worked, In the past I had always used hostname to assign a static IP on other systems but wasn't sure it about openwrt and assumed all the fields on LUCI had to be completed.

Screenshot_2018-07-24_00-05-38

/etc/config/dhcp

config host
	option name 'Test-PC'
	option dns '1'
	option ip '192.168.1.100'

Thanks

So basically I just need to put the User's actual host name and delete the mac field altogether and then it will serve the static IP to that user depending on whether it finds that hostname or not?

[Edit] It's fixed, Providing only the hostname works well enough just like the mac address. Thanks