Hi,
suddently few days ago in routeros 6.48.3 the command "/ip address get " didn’t work anymore.
More in details, I used to get the dynamic address of PPPoE interface as follows:
/ip address get [find interface=pppoe-vdsl ] address
After 21/07/2021 it gives empty string, and nothing has changed in configuration and routeros version.
I found a workaround, currently the following syntax is working:
/ip address get [:pick [/ip address find interface=vrrp_vdsl ] 0] address
Does everybody know the reason of this strange behaviour?
TIA,
rik
Your command is not a workaround, simply also :pick can do what described here.
[:pick array 0] = get element 0 of array (the array start with first element numbered 0)
The command “get interface address” return everytime (if interface exist) one array because a single interface can have one or more IP.
This display how much IPs are on that interface:
:put [:len [/ip address find where interface=vrrp_vdsl]]
The index start with 0, the 0 is the first address, and for obtain the first IP:
:put [/ip address get ([find where interface=vrrp_vdsl]->0) address]
and for obtain the second IP, with index 1:
:put [/ip address get ([find where interface=vrrp_vdsl]->1) address]
and so on…
@rextended
Thank you very much for your explaination: everything is clear.
My trouble was about the reason because the behaviour was different when using pick (IP shown) or not (empty string shown).
Now the behaviour is back to the expected: both syntax give back the single IP configured to the interface.
So I’m unable to troubleshoot it further… but there is no need to do it.
Anyway, thanks again for your clarification.
Rik
Ok, I know how clear your last doubt, if the interface can have only one IP, the result are one string and that works:
:put [/ip address get [find where interface=<pppoe-xxxxxxx>] address]
[rextended@MATRIX] > :put [:len [/ip address find where interface=ether1]]
1
[rextended@MATRIX] > :put [:len [/ip address find where interface=ether3]]
2
[rextended@MATRIX] > :put [get [find where interface=ether1] address]
192.168.1.1/24
[rextended@MATRIX] > :put [get [find where interface=ether3] address]
invalid internal item number
[rextended@MATRIX] > :put [/ip address get ([find where interface=ether3]->0) address]
192.168.3.1/24
[rextended@MATRIX] > :put [/ip address get ([find where interface=ether3]->1) address]
19.16.3.1/24