mikrotikrouter-os

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.


Solution

  • 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 ..).