Page 1 of 1

local address to netwatch host

Posted: Mon Jun 28, 2021 1:43 pm
by runbound
pls help i need a script to get the local address in interface pppoe status and put it on netwatch host.

Re: local address to netwatch host

Posted: Mon Jun 28, 2021 3:15 pm
by rextended
replace pppoe-out1 with your right name
:put [/ip address get [find where interface=pppoe-out1] address]

Re: local address to netwatch host

Posted: Mon Jun 28, 2021 4:08 pm
by runbound
thanks sir. but how to put it in the netwatch host the ip address coming from interface pppoe-out1

Re: local address to netwatch host

Posted: Mon Jun 28, 2021 4:16 pm
by rextended
paste this on terminal and after that you can add function to the script inside netwatch events, but do not change what already is inside.
/tool netwatch
add comment=pppoe-out1 down-script=":local ipx [/ip address get [find where interface=pppoe-out1] address]\r\
    \n:local ip [:pick \$ipx -1 [:find \$ipx \"/\" -1]]\r\
    \n/tool netwatch\r\
    \n:local idwatch [find where comment=pppoe-out1]\r\
    \n:if (\$ip != [get \$idwatch host]) do={\r\
    \n set \$idwatch host=\$ip\r\
    \n}\r\
    \n" host=1.1.1.1 up-script=":local ipx [/ip address get [find where interface=pppoe-out1] address]\r\
    \n:local ip [:pick \$ipx -1 [:find \$ipx \"/\" -1]]\r\
    \n/tool netwatch\r\
    \n:local idwatch [find where comment=pppoe-out1]\r\
    \n:if (\$ip != [get \$idwatch host]) do={\r\
    \n set \$idwatch host=\$ip\r\
    \n}\r\
    \n"

Re: local address to netwatch host  [SOLVED]

Posted: Mon Jun 28, 2021 6:48 pm
by runbound
thank you very much sir. it solve my problem

Re: local address to netwatch host

Posted: Mon Jun 28, 2021 6:50 pm
by rextended
Thank you, you are really very kind.
It's a pleasure helping you.