Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mikrotik Scripting: Get Interface IP

I want to get the local-address property of a pppoe-client interface, which is my public internet IP address.

Assuming that the name of the interface is my-pppoe-out, what is the proper interface pppoe-client get command to use?

I couldn't find anything useful in the official wiki for this.

like image 794
David Refoua Avatar asked Mar 12 '26 01:03

David Refoua


1 Answers

You can't get the IP directly on the command-line, you must use a script to do this.

:local ip [/ip address get [find interface="pppoe-out1"] address ];
:put "IP: $ip"

Then you can do whatever you want with the variable $ip (here i just write it in the console) like updating a dyndns, etc.

To use this script, either copypaste it in a file like "ip.rsc" and then type "import ip.rsc" to execute it, or put it on a routerOS script (/system script add ..).

like image 128
Benoit PHILIPPON Avatar answered Mar 14 '26 19:03

Benoit PHILIPPON