ASUS WRT Device Tracking Issues - dnsmasq been replaced with udhcpd

Hi All

I’ve recently bought an ASUS DSL-AC56U Modem and using it via NBN direct to the house on the WAN PPTP connection (so not using a DSL connection). I bought the ASUS modem as i noticed that ASUSWRT is supported by Home Assistant.

I am running the current firmware from ASUS, ASUSWRT Version 1.1.2.2_36 (28/3/2017). I also have both SSH and Telnet enabled in ASUSWRT. I can successfully telnet and SSH onto the router using putty, so I know my settings in ASUSWRT should support Home Assistant for both SSH and Telnet.

Initially i tried connecting from Home Assistant using a SSH connection:
device_tracker (Configuration.yaml):

  • platform: asuswrt
    host: 192.168.1.1
    username: ‘admin’
    password: ‘secretpassword’
    protocol: ssh
    port: 22
    mode: router
    track_new_devices: yes
    interval_seconds: 10
    consider_home: 180

But i noticed that SSH was having issues getting a connection issue in the home-assistant.log:
“17-04-02 19:57:39 ERROR (Thread-10) [homeassistant.components.device_tracker.asuswrt] Unable to connect via SSH: could not set shell prompt (received: b” unset PROMPT_COMMAND\r\n# PS1=’[PEXPECT]\$ ‘\r\n[PEXPECT]\$ set prompt=’[PEXPECT]\$ '\r\n[PEXPECT]\$ “, expected: '\[PEXPECT\][\$\#] ').”

After reading through the forum i noticed quite a few other users noted that SSH connections didnt work, and instead switched to Telnet connections with success.

So I switched to Telnet, configuration.yaml below:
device_tracker:

  • platform: asuswrt
    host: 192.168.1.1
    username: ‘admin’
    password: ‘secretpassword’
    protocol: telnet
    mode: router
    track_new_devices: yes
    interval_seconds: 10
    consider_home: 180

However I got a new error when viewing the home-assistant.log relating to a missing dnsmasq.leases file:
17-04-02 20:02:26 WARNING (Thread-8) [homeassistant.components.device_tracker.asuswrt] Could not parse lease row: b’cat: /var/lib/misc/dnsmasq.leases: No such file or directory\r’

After telneting onto the router i discovered that /var/lib folder didnt even exist, let alone /var/lib/misc/dnsmasq.leases? I also found that dnsmasq isnt even on the router, it seems that the new ASUS routers are running ‘udhcpd’ for DNS stuff. When I looked in /usr/sbin/, there was no reference to dnsmasq at all, but there was udhcpd which was running.

I did find a few files which contain DHCP leases in ‘/etc/udhcpd.leases’ & ‘/etc/udhcp_lease’, which appear to contain similar information to the ‘dnsmasq.leases’ file.

So I’m curious if anyone else has stumbled across this issue with ASUS running udhcp instead of dnsmasq, and if there are any work arounds?

I’m also very keen to know what the process is for raising this up to the folks who are maintaining the ASUSWRT component code, ideally to update the component to work with the current firmware and support for udhcp leases.

Failing that I might be taking my brand new ASUS modem router back and switching it over to a Netgear router and hope that has better compatibility with Home Assistant for Device Tracking.

Regards
Craig

I’m running ASUS DSL-AC68U with stock firmware and can connect via SSH.
All I did was to run ssh-keygen -t rsa -b 4096 -C "key coment" as the user homeassistant and add the key to the router.
Before adding the router to my ha config, I just ran ssh -v user@router to make sure I can connect ok.
Asus firmware version is : 3.0.0.4.380_7361-g4336188.

My ha config looks like this

platform: asuswrt
host: 192.168.1.1
username: !secret user_Asus
ssh_key: /home/homeassistant/.ssh/id_rsa
track_new_devices: yes

Hi Mukund

Thanks for the information about SSH, I’ll give that a try tonight.

So does that mean that your DSL-AC68U is running dnsmasq for the dns services and keeping track of leases etc? (so /var/lib/misc/dnsmasq.leases exists on your router?)

Craig

Hi Craig
I’m not entirely sure. I’ll check it when I get home tonight.

Mukund

Hi Craig

Yes, I have the dnsmasq.leases file.

admin@(none):/tmp/home/root# ls -l /var/lib/misc
-rw-r--r--    1 admin    root           667 Apr  5 18:11 dnsmasq.leases

Maybe switch your router back to the stock firmware??

Mukund

Thanks for looking Mukund, strange that the ASUS DSL-AC56U Modem doesnt run dnsmasq too :frowning2:

Hi Craig
I’m assuming you are running stock firmware.

Have you looked at https://github.com/RMerl/asuswrt-merlin?? Just did a quick search and Search results are positive for dnsmasq.

Mukund

Hi Mukund

Yeah Im running the latest and greatest ASUS firmware ( Version 1.1.2.2_36 released 28/3/2017) direct from ASUS (https://www.asus.com/au/Networking/DSL-AC56U/HelpDesk_Download/)

I read up on Merlin, and there it sounds very likely that Merlin hasn’t been designed for DSL type ASUS modem’s and wont support the DSL functionality, and potentially will brick the modem.

I’m just looking into forking the Home Assistant git repo and looking at tweaking the ASUSWRT.py component library to handle udhcpd leases. I’m just reading up on the dev notes now.

I’ll keep you posted
Craig

Sounds like a plan. Let me know how you go.

Hi Mukund

I had a look at the python code and I was having some issues re-working the regex to handle to the new formatting of the dhcpd_lease file and time ran out. So i ended up taking the ASUS DSL-AC56U back to the shop and paid the difference to get the AC68U model the same as you.

And yep the dnsmasq.lease is right where it should be, and happy days my device tracking is working as it should be now.

Thanks for your help looking up that dnsmasq was present on the AC68U model :slight_smile:

Craig

Maybe using the web interface given the example here will be easier?

Hi Craig

Good that its working for you. I think the 68U is better anyway regardless of the HA compatibility.

Mukund

hey guys hope someone can help me i use asus wrt for device tracking it worcks fine
but every day around midday all my devices change to away even though they are at home
i have RT-AC68P
this is my config
device_tracker:
- platform: asuswrt
host: my ip address
username: mysecretusername
password: mysecretpassword
protocol: telnet
interval_seconds: 10
consider_home: 180
track_new_devices: yes

device_tracker:
  - platform: asuswrt
    host: my ip address
    username: mysecretusername
    password: mysecretpassword
    protocol: telnet
    interval_seconds: 10
    consider_home: 180
    track_new_devices: yes

Hi Kem

This is probably due to the ip leases your router assigns expiring. I dare so you have a 24 hr lease period setting on your router and you would have done a router reboot sometime in the recent past around midday which reset all the existing device ip renewals.

You should be able to increase the expiry period for assigned ip addresses on the router. But at some stage they will expire. But the device should literally flick offline for a few seconds and then be back on the network again with the same ip but with a fresh renewal period.

Craig

thanks for the replay can you point me on where on my router settings should i look and ones again thanks

Kem

The IP lease setting can be found in LAN - DHCP Server Tab, there will be a lease time variable you can set. Mine is currently set at 86,400 seconds (24 hrs), which is the default.

Craig

i got thank you so much for taking the time help me

Hi,
I’m trying to use AsusWRT on my AC68U
I tried both telnet and ssh by username and password. Same return as SSH enable?
on the router log. it says login attempt from nonexsistent user.
I can login from my raspberry pi by ssh [email protected] it works.
Any suggestion?

device_tracker:

platform: asuswrt
host: 192.168.*****
username: admin
password: *******
protocal: telnet
mode: router
protocal: telnet
track_new_devices: yes
interval_seconds: 61
consider_home: 180

this my be a dumb question but it happen to me have you enable telnet on your router ??