Community discussions

MikroTik App
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

local address to netwatch host

Mon Jun 28, 2021 1:43 pm

pls help i need a script to get the local address in interface pppoe status and put it on netwatch host.
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address to netwatch host

Mon Jun 28, 2021 3:15 pm

replace pppoe-out1 with your right name
:put [/ip address get [find where interface=pppoe-out1] address]
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: local address to netwatch host

Mon Jun 28, 2021 4:08 pm

thanks sir. but how to put it in the netwatch host the ip address coming from interface pppoe-out1
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address to netwatch host

Mon Jun 28, 2021 4:16 pm

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"
 
runbound
Member Candidate
Member Candidate
Topic Author
Posts: 125
Joined: Fri Apr 19, 2013 9:28 am

Re: local address to netwatch host  [SOLVED]

Mon Jun 28, 2021 6:48 pm

thank you very much sir. it solve my problem
 
User avatar
rextended
Forum Guru
Forum Guru
Posts: 11982
Joined: Tue Feb 25, 2014 12:49 pm
Location: Italy
Contact:

Re: local address to netwatch host

Mon Jun 28, 2021 6:50 pm

Thank you, you are really very kind.
It's a pleasure helping you.

Who is online

Users browsing this forum: No registered users and 19 guests