Associate MAC address with configurable name

Hi,

*** EDITED and changed hostname to configurable name ***

Does anyone know how I can associate MAC addresses with a configurable name?

Mable-Notebook 192.168.0.108 88:53:xx:xx:xx:xx 1h 30m 42s
? 192.168.0.237 e8:9d:xx:xx:xx:xx 1h 30m 42s
android-3c13f80a78e8da54 192.168.0.158 ec:9b:xx:xx:xx:xx 0h 2m 59s
RedmiNote2-Redmi 192.168.0.184 20:82:xx:xx:xx:xx 1h 56m 2

My current DHCP table looks like the above. Not very useful, especially, when there's the "?" as a host name, and "android-3c13...". I can't get on those hosts to give them names, so I would like a way to name them somewhere on the router, without having to give them a specific IP address.

Ideas?

1 Like

You can't associate MAC addresses with hostnames, however.

You can create static DHCP leases, thereby assigning a reserved IP address to DHCP requests originating from a specific MAC address. With this, you can additionally also create local DNS entries (overrides) for your domain (.lan, by default) to point towards your local (or even remote) IPs. The combination of these two should provide you with the desired functionality.

Using luci, both are easily available (in a combined form) via "Network" --> "DHCP and DNS" (/cgi-bin/luci/admin/network/dhcp) under "static leases" (it also allows setting up IPv6 suffixes and MAC specific lease times).

2 Likes

Thanks, slh.

What I meant wasn't a hostname. I meant a configurable name that makes sense.

And without having to assign a static DHCP lease.

That defeats the purpose of having DHCP.

Not really, static DHCP leases (configured on the DHCPd, not the clients) are a primary functionality of (enterprise-) DHCP setups.

If your client does submit its hostname as part of the DHCP request, dnsmasq will remember it and the MAC address mapping dynamically - however neither will survive a reboot, nor does that allow editing the assignment.

Which is why I'd like something that can associate a name with a MAC address.

When I bought a Linksys WRT1900AC, it has this functionality, and the functionality is not DHCP.
It doesn't depend on the IP address as well.

1 Like

Yes it is possible to force a name for a DHCP client.

Got to LuCI => DHCP and DNS => General Settings => Static Leases, set hostname and mac-address and you're done.

I'm using this feature for clients not sending a hostname via DHCP.

2 Likes

I think what he actually wants is to display the name in a way that's more human-readable(by configuring it). not to actually change the hostname given by DHCP

2 Likes

True and I especially request that feature too.
I'm using my openwrt devices as dumb APs that connect a l2-network to wifi.
The DHCP-server is resiging on another device, but I still want to show proper hostnames in the wifi-stats.

A dumb AP does not handle DHCP requests, it just passes the packet to the main router, so it does not have any information about client names. It would have to somehow request that information from the DHCP, and as far as I know, there isn't a protocol to handle such requests... not an easy task.

Why are people talking about DHCP requests???

This is not a DHCP request. This is just to request a configurable name to be displayed beside the device on the DHCP area of the OpenWRT.

Do people not read?

This would be the logic:

if Dictionary.TryGet(DeviceMac, Name) then
DeviceItem.Name := Name;

What the above means is that look in the dictionary for a key matching the device mac address, and if it matches, retrieves the value and place it into the variable Name.

If that succeeds, in the device item display on the OpenWRT, assign the name to the name column.

If I knew how to modify OpenWRT, or any Lua script, I would be able to do this in a few minutes.

Here's what I need, for people who have difficulty visualizing or reading/understanding what I wrote

Mac Address | Host Name | IP Address | Configurable Display Name
40:22:33:44 | XyZAndroid | 192.168.1.1 | My Android hand phone

2 Likes

What dictionary are you talking about?

You are asking to modify the page where DHCP information is being displayed, but those who talk about DHCP are who do not read?

Haven't you noticed I was answering to @Double-G, not you?

If I dare saying that I read and understood your request, at least for me, I edited the file /etc/dnsmasq.conf and add lines like:

dhcp-host=11:22:33:44:55:66,MyBelovedDevice

1 Like

When you edit /etc/dnsmasq.conf and use the dhcp-host option, you're associating host name with the mac address.

Again, I am not talking about hostname.

The DHCP page is the only place where the mac address shows up.

Fortunately / unfortunately, the time for associating a configurable display name (not hostname) has passed, so I will not be pursuing this any more.

If I would work on this, I would be editing the DHCP page, and when it is being displayed, I would lookup existing mac address that have been given a lease, and then read another file, where mac addresses and associated display names are stored.

Then, I would store the mac address and the associated display names in a lookup table.
Then for each mac address that have a lease, I would lookup in the lookup table, get the display name, and display it.

This algorithm doesn't require any sending or receiving any DHCP requests, since all the mac addresses that have a lease are already stored somewhere in a file.

The OpenWrt method would be to:

  • edit /etc/config/dhcp
  • use the UCI commands; or
  • add the Static Lease in the LuCI web GUI.
config host
	option name 'MyBelovedDevice'
	option mac '22:33:44:55:66'

I understand the OP rather use a non-standard name through some self-made script (i.e. something that doesn't exist in out-the-box OpenWrt), so this doesn't help with the OP's chosen method to solve the problem.

1 Like