Get the Public IP / WAN IP of the Turris Omnia

For STUN: If you have python, you could try pystun3 (or borrow some of the code for your own application). That seems to work on my machine behind an Omnia. It has a built in list of publicly usable servers so you don’t need to provide your own, but it does require a server outside on the internet which you said you didn’t want. Also, I think google has some servers although these aren’t on the list in pystun3. Here’s how running pystun3 looks on my machine:

(.venv) pystun3 % pystun3
NAT Type: Restric NAT
External IP: 84.92.41.50
External Port: 54320
Press any key to continue
(.venv) pystun3 %

That Press any key to continue is rather annoying so you might want to fork and edit the code to remove it for your application.

There are also libraries for other languages (javascript, etc.) if you prefer to have the answer in a script written in those.

=====

For SNMP it’s going to be much more involved, so I’ll leave it up to you to find that solution elsewhere. You’ll need an SNMP daemon running on the Omnia, and then a client on your local device. Then, make sure you get the correct OID for the port IP address. Probably set up a read-only community string for some security. This is the original protocol-based solution for getting information from a router… but I’m not an SNMP expert and have no desire to change that!

The mention above of DDNS is also an interesting one. Still requires some external internet stuff but if you had DDNS on the Omnia then you could just look up that domain name on the local device and get the answer. It separates the concerns in a very neat way.

Anyhow, these are all more complicated than the SSH based solutions. Perhaps @moeller0 and I would find agreement that you could create another non-root user account on the omnia and store the ssh key for access to that account on your local device to run the script… Perhaps even cleverly create a user account where the “shell” merely returned the IP address.

Maybe… but in your model clearly the router seems more important and trusted than the endhost, so maybe storing the endhost’s key on the router and having the router push something to the endhost’s filesystem (and have a script do a blocking wait on a file being changed there) might do the trick.

I expect that it might be not too hard to create a very restricted user and ssh to that account instead of root’s.

1 Like

This is the approach I use now.
I use a Scheduled Task on the Turris Omnia with ssh. I had to create an SSH Key in order to get this to work.

0 * * * * IP=$(ip -f inet addr show pppoe-wan | sed -En -e ‘s/.inet ([0-9.]+)./\1/p’); ssh root@X.X.X.X “echo “$IP” > /IP.txt”

1 Like