Get the Public IP / WAN IP of the Turris Omnia


is it possible to get the Public IP / WAN IP of the Turris Omnia with a Script and without external service / website.



As for public IP (even if you’re behind a NAT), e.g. curl

(you can add -4 or -6 to be specific about IP version)

Yes, but I do not want to use an external service / website. I want to get the information directly from the Omnia.

ip -4 a show dev eth2
if you don’t mind that the output has lots of other information as well.

No I need only the ipv4 address and I want to do this from a Raspberry Pi or another external Device with a Script. Turris Omnia does not have an API or something similar to get this?

You could look into the STUN protocol, or later similar protocols to solve this problem. They do all require servers on the internet. Seems that google (perhaps among others) runs publicly accessible STUN servers, but I haven’t tried any of them.

For me it was /sbin/ifconfig pppoe-wan | grep 'inet addr:' | cut -d: -f2 | a wk '{ print $1}'

1 Like

But this command I have to run in SSH on the Turris Omnia or?

For sure - how should external devices read Omnia’s internal data?
Edit: you can grand ssh-access (via sshfs) to your pi to bypass that obstacle.

1 Like

I use this in crontab :

5 6,12,18,22 * * * create_notification -s news $(ifconfig pppoe-wan|grep “inet addr:”|awk ‘{print $2}’|awk -F : ‘{print $2}’)

sends an notification about WAN IP at 6:00, 12:00, 18:00, 22:00

1 Like

But where will this notification be published or how can i read this?

This is published on Foris notifications, for which you can get updates per email.
Options for this are either collecting this email via your pi or maybe calling an API (which I’m not aware of).

Or give your Omnia access to a special folder on your pi via sshfs and place a file with the output that @AreYouLoco posted.

on an omnia:

root@turris:~# /sbin/ifconfig pppoe-wan | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'

remotely from a different computer ( is my omnia’s IP address):

bash-3.2$ ssh root@ /sbin/ifconfig pppoe-wan | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'

note since I distributed the keys properly, accessing the omnia via ssh does not prompt for a password.


Of course, same as any other *nix device.

Is there also another possibility to do this without SSH, from a external device?

How do you imagine connecting to Omnia to get the data?
There is no API. Its either ssh or putting IP in a file and accessing the file remotely via SSHFS/Samba

Or the other way around as someone mentioned already.

1 Like

Sure you could wing it and say write a file with the IP on every IP change and serve this out via the web-server (also used for the GUI). Or think about packaging that via SNMP, or send an email on every change to a specific host with the new IP address. The sky is your limit here.

If I might ask, why not use SSH though? It is quite powerful and essentially allows you to do anything you could do in a terminal window.

Well, I’d be reluctant to have the private key for root on my omnia just sitting around on some random device inside my network …

Back to the original question: the OP asked if there was an API to get the information. For networking stuff, we usually substitute the word Protocol for API. Given that I thought about things from the IETF and came up with STUN, which was designed for exactly what I imagine the use case is: understanding what the internet routable address is for a device behind a NAT device. It uses servers on the internet because the device is not expected to have a trust relationship with that NAT device (as in many instances it would not: for example, where the NAT device is owned by a business or ISP, as in a cafe, hotel, or CGN from an ISP). STUN can determine the publicly routable address without the cooperation of the NAT device or devices.

It now occurs to me after reading some more of the discussion here that SNMP should also be able to answer this more limited question, of what the IP address is on a particular interface for a router where there is some trust relationship, in particular where both the device asking and the router are owned by the same person. It looks like OpenWRT does package a few different SNMP daemons. I would just say that while both STUN and SNMP start with the word “Simple” … SNMP has always baffled me!

But if you want to exploit that trust relationship you’ll need to have some sort of shared credential to prove it. It could be an SSH key as proposed above. It could be a community string for SNMP. It could be some sort of SMB mount access as also proposed above.

Good luck!

This question was more directed at the OP… also not sure the host in question falls into the ‘some random device’ category for the OP…

This is IMHO not a bad idea, although not what the OP asked for:

STUN requires dedicated servers…

At that point it becomes equally simple to use A DDNS service on the primary router and use something like dig @ +shortto have the pi pick up the address, except that also requires external services… (this is IMHO elegant as resolving names to IP addresses is exactly what DNS was created for…)

Ok, I like the use of SNMP or STUN, but STUN needs a Server and SNMP not, correct?
Which of these two is less komplex to implement and how can I implement these?