-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathdynamic gateway changer.rsc
More file actions
27 lines (26 loc) · 1.07 KB
/
dynamic gateway changer.rsc
File metadata and controls
27 lines (26 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#Tools Netwatch
:local pppoe-iface YOUR_DYNAMIC_INTERFACE
:local ISP-chk YOUR_RECURSIVE_ROUTE_COMMENT
:log warning "Starting ISP check gateway";
:local gate0 [/ip route get [find comment=$ISP-chk ] gateway ]
:local gate1 [/ip address get value-name=network [find interface=$pppoe-iface]]
:if ( $gate0 != $gate1 ) do={
:log warning "update gateway";
/ip route set [find comment=$ISP-chk] gateway=$gate1
:log warning "Change gateway Complete!";
###########################
#System Scheduler
:local pppoe-iface YOUR_DYNAMIC_INTERFACE
:local ISP-chk YOUR_RECURSIVE_ROUTE_COMMENT
:log warning "Starting ISP check gateway";
:local gate0 [/ip route get [find comment=$ISP-chk ] gateway ]
:local gate1 [/ip address get value-name=network [find interface=$pppoe-iface]]
:if ( $gate0 != $gate1 ) do={
:local status [/tool netwatch get [ find comment=$ISP-chk ] status ]
:if ( $status != down ) do={
:local updown [ /interface get $pppoe-iface running ]
:if ( $updown = true ) do={
:log warning "update gateway";
/ip route set [find comment=$ISP-chk] gateway=$gate1
:log warning "Change gateway Complete!";
}}}