Community discussions

just joined
Topic Author
Posts: 1
Joined: Wed May 15, 2019 10:27 pm

Need help with script

Wed May 15, 2019 10:51 pm

Need help i'm not quite sure if my script is correct, can somebody check it and correct me where did it go wrong?. Whenever i run it doesn't work.

So what i did was to detect my dhcp-client's ip address and gateway and check my firewall rule and routes if they have same values if not my firewall rule and routes shall copy my dhcp-client's ip address and gateway

Please help and sorry for my bad english.
:log info "checking gateway";
:local fwIP [ /ip firewall mangle get [find comment="ispdstnat"] dst-address];
:local newgwIP [ /ip dhcp-client get [find interface="ISP1-PldtHomeFibr"] gateway]; 
:local newrouteIP [ /ip routes get [find comment="wanmarkgwIP"] gateway];
:local newIP [ /ip address get [find interface="ISP1-PldtHomeFibr"] address];
:put [:pick $newIP 0 [:find $newIP "/"]];

:if ($newgwIP != $wanmarkgwIP) do={

:put "gateway ip $wanmarkgwIP changed to $newgwIP";

:if ($newIP != $fwIP) do={

:put "ip address $fwIP changed to $newIP";

:log info "done changing fw dst address and route gateway";

Who is online

Users browsing this forum: No registered users and 8 guests