Sensor fetching WAN IP from router

I use Nabu Casa service (everyone should IMO) for accessing HA remotely and was looking for a way to know my WAN IP address if I need to VPN my home network. My Asus router does support various DDNS services but I wasn’t interested to go that way as I don’t like to subscribe online services. My solution was to create a key using puttygen (without passphrase), enable SSH with newly created key in my router, copy key files to /config/ssh into HA with permissions then simply add sensor to config:

sensor:

#### Sensor for showing WAN IP address from Asus RT-AX88U using ssh
  - platform: command_line
    name: WAN_IP
    command: ssh -i /config/ssh/asus_rtax88u_private -o StrictHostKeyChecking=no [email protected] "ifconfig eth0 | grep inet | sed -e 's/.*addr:\([^ ]*\) .*/\1/'"

A lot of information can be pull from those Asus router when using terminal, feel free to share the ones you like to monitor.

2 Likes

Did you try the DNS IP integration?

1 Like

No as I have other projects involving failover/dual-wan LTE/5G link automations I prefer fetching IP addresses binded to each interfaces.

I think a smnp lookup would be better and you can then limit it to read access only on the router for security.

SNMP would be useful but has limits, as for securing my router, opening SSH on LAN side with sole key inside HA isn’t concerning. If someone was to hack my HA server, what he could do with my router would not be significant vs all threats possible with devices he could control. :wink:

I understand you guys aren’t used with wrt routers and everything you could do with those (cron jobs, scripting).

I know what a WRT flash device can and you are probably right, that when a breach that can read your SSH command line occur, then that will be the least of your problems. :slight_smile:

I would still prefer to extract valus from the router through SMNP, though.
The WAN IP I would extract through a website like whatismyip.com, since I would get the true public IP.
The other method would fail with CGN.

I have an RT-AC2900 and already configured the asus-WRT plugin in Home Assisstant. But I would like to configure an firmware update sensor.

My previous router (AC68U) had the possibility to work with SMNP, but seems it’s removed in the AC86U/ AC2900.

Is it possible to fetch firmware update information by using the “command_line sensor”?

If you can find the information, then a command line script can get it too.
It might not be easy, but it’s possible.
You need to make a new post with this question and ask for help with the scriptmake a description of what you do to find it, so people know which steps to make in the script.