Community discussions

MikroTik App
 
User avatar
Jotne
Forum Guru
Forum Guru
Topic Author
Posts: 3297
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Finding public IP

Thu Jul 26, 2018 2:14 pm

I did find a in a script how to find public IP on RouterOS
:put [/ip address get [find interface="ether1"] address];
My problem is that the outside interface may be named something other than ether1.

So after som testing I come up with this:
:put [/ip address get [find interface=[/ip route get [find dst-address=0.0.0.0/0] vrf-interface]] address]
[/ip route get [find dst-address=0.0.0.0/0] vrf-interface]
This should find the interface name on the interface with route sending you to internet.

Anyone see anything wrong with this?
Will it work with all MT?

Who is online

Users browsing this forum: No registered users and 30 guests