Community discussions

MikroTik App
 
JimFundament
just joined
Topic Author
Posts: 2
Joined: Tue Sep 05, 2023 2:30 pm

get current-endpoint-address from peer of wireguard

Tue Sep 05, 2023 2:43 pm

Hi guys, is there any possible to get current-endpoint-address in peer of wireguard, I literally need this address
it seems can't use the "get" to get this value
does anyone has any means?
 
holvoetn
Forum Guru
Forum Guru
Posts: 5500
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: get current-endpoint-address from peer of wireguard

Tue Sep 05, 2023 3:01 pm

print works for both.
But get doesn't, neither for endpoint-address nor current-endpoint-address.
[xyz@RB5009_KT] /interface/wireguard/peers> print detail
Flags: X - disabled; D - dynamic
0 interface=WGWork public-key="<edit1>"
endpoint-address=<edit2>.sn.mynetname.net endpoint-port=<edit3> current-endpoint-address=<edit4>
current-endpoint-port=<edit3> allowed-address=10.255.250.0/24 persistent-keepalive=25s rx=47.1MiB tx=60.3MiB
last-handshake=44s
[xyz@RB5009_KT] /interface/wireguard/peers> get value-name=current-endpoint-address number=0
[xyz@RB5009_KT] /interface/wireguard/peers> get value-name=endpoint-address number=0
[xyz@RB5009_KT] /interface/wireguard/peers>

Odd ...

Best to shoot a mail to support.
 
holvoetn
Forum Guru
Forum Guru
Posts: 5500
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: get current-endpoint-address from peer of wireguard

Tue Sep 05, 2023 3:03 pm

Ah wait ...
Try this as alternative:
/interface/wireguard/peers> print proplist=current-endpoint-address
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: get current-endpoint-address from peer of wireguard

Tue Sep 05, 2023 5:46 pm

(
[xyz@RB5009_KT] /interface/wireguard/peers> get value-name=current-endpoint-address number=0
this command, if do not do any error, do not print anything if you do not use :put.....
and at least bust be :put [get 0 current-endpoint-address]
)
 
holvoetn
Forum Guru
Forum Guru
Posts: 5500
Joined: Tue Apr 13, 2021 2:14 am
Location: Belgium

Re: get current-endpoint-address from peer of wireguard

Tue Sep 05, 2023 6:04 pm

Hmmm ... nice one !
[xyz@RB5009_KT] > interf wireg peer
[xyz@RB5009_KT] /interface/wireguard/peers> :put [get value-name=current-endpoint-address number=0]
AA.BBB.CCC.DDD
 
JimFundament
just joined
Topic Author
Posts: 2
Joined: Tue Sep 05, 2023 2:30 pm

Re: get current-endpoint-address from peer of wireguard

Wed Sep 06, 2023 4:54 am

and this one is also effective and standardized
# /interface/wireguard/peers/get [find interface=wireguard1] current-endpoint-address;
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 12014
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: get current-endpoint-address from peer of wireguard

Wed Sep 06, 2023 10:30 am

and this one is also effective and standardized
# /interface/wireguard/peers/get [find interface=wireguard1] current-endpoint-address;
If the interface name is already known, simply…
/interface wireguard peers get wireguard1 current-endpoint-address

If the name is from a variable, just...
/interface wireguard peers get $iname current-endpoint-address

On all 3 cases on this post, wireguard1 must already exist.
So, for prevent errors, first must be checked if [find where interface=wireguard1] give any result.
:if ([:len [find where interface=wireguard1]] = 1) do={ ... }

Who is online

Users browsing this forum: No registered users and 5 guests