Control-D-Inc / ctrld

A highly configurable, multi-protocol DNS forwarding proxy
MIT License
444 stars 22 forks source link

Duplicate devices on router #54

Closed pmcarrion closed 1 year ago

pmcarrion commented 1 year ago

ctrld on my Asuswrt-Merlin router detects a device as expected, but is showing two devices in the clients section with the same IP and MAC addresses. One is named correctly, and the other one has an asterisk. Both are the same device.

Is this a known issue with some devices?

cuonglm commented 1 year ago

@pmcarrion Could you please give me your dnsmasq lease file (with sensitive information reducted)?

pmcarrion commented 1 year ago

@cuonglm Sure, please tell me how to get that file!

yegors commented 1 year ago

@pmcarrion Email to me: yegor@controld.com and I'll forward it.

cuonglm commented 1 year ago

@cuonglm Sure, please tell me how to get that file!

On Asus Merlin, the lease file is /var/lib/misc/dnsmasq.leases

pmcarrion commented 1 year ago

@yegors I just emailed you the file.

cuonglm commented 1 year ago

@pmcarrion What appears later in your dashboard? The entry with * hostname or the entry with real hostname?

pmcarrion commented 1 year ago

@cuonglm The entry with the real name appears later.

cuonglm commented 1 year ago

@cuonglm The entry with the real name appears later.

Thanks.

Client hostname will be asterisk if it does not specify the hostname when requesting DHCP lease.

Maybe related: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=32827

So at least ctrld is working properly when changes are made to lease file:

pmcarrion commented 1 year ago

All my devices have a hostname in the router, but I guess this information isn't always passed on as it should.

Some devices always show an asterisk instead of a hostname, but these are not duplicated.

Perhaps you can implement two options in ctrld and the Control D Dashboard: 1) Ability to rename devices (useful for those only named with an asterisk). 2) Ability to merge devices by MAC address in case of duplicates.

cuonglm commented 1 year ago

All my devices have a hostname in the router, but I guess this information isn't always passed on as it should.

Do you mean pass from ctrld to Control D Dashboard?

Then the answer is no, the hostname, once detected will always be passed as-is. The main thing is that DHCP client can hidden its hostname when request lease from DHCP server. For example, here's my /etc/dhcp/dhclient.conf:

# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#   man page for more information about the syntax of this file
#   and a more comprehensive list of the parameters understood by
#   dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#   not leave anything out (like the domain name, for example), then
#   few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

# send host-name = gethostname();
send host-name = "";
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;

Notice I configured it to send empty hostname. After requesting address from DHCP server:

$ sudo dhclient -r
$ sudo dhclient

Now looking at router lease file:

root@DD-WRT:~# cat /tmp/dnsmasq.leases 
1686142869 REDUCTED 192.168.0.209 * * 9

You can see * as hostname, because client did not send it to DHCP server.

pmcarrion commented 1 year ago
  1. Ability to rename devices (useful for those only named with an asterisk).
  2. Ability to merge devices by MAC address in case of duplicates.

I see… then these suggestions for the Control D Dashboard would be very helpful.

yegors commented 1 year ago
  1. The list should show what is known to the router, deviating from the "source of truth" is not a good idea.
  2. That could be a good UI option, we will think about this one.
pmcarrion commented 1 year ago
  1. The list should show what is known to the router, deviating from the "source of truth" is not a good idea.

You can maintain the original * name next to the desired hostname. This is useful for identifying devices on networks with several unidentified devices.

My network currently reports 6 asterisks to Control D. It's a hassle to go back to the router's dashboard and search for the unidentified device by MAC address.

yegors commented 1 year ago

The * is as a result of WiFI Privacy being enabled on an Apple device, If you toggle it OFF for the WiFI network, a proper hostname will be shown.

NoSync commented 11 months ago
  1. The list should show what is known to the router, deviating from the "source of truth" is not a good idea.
  2. That could be a good UI option, we will think about this one.

@yegors any news about feature 2? That would be a great addition, together with the possibility to remove old clients from the client list.