:set q 1
:set st 1
:foreach i in=[/ip fire add find list=gw disable=no] do={
:set w [/ip fire addr get $i address]
:if ( $q > 1 ) do={
:set st ($st . , . $w)
} else={
:set st $w
}
:set q ($q+1)
}
:set cek [/ip ro get [/ip ro find dst-address=0.0.0.0/0] gateway]
:if ($cek = $st) do={
:log info ("ip route sama .... " . $st)
} else={
:log info ("ip route beda, ganti dong .... " . $st)
/ip ro set [find dst-address=0.0.0.0/0] gateway=$st
}
untuk di tiap netwatch
0 host=10.10.10.100 timeout=1s interval=10s since=jan/01/2000 01:18:12
status=up up-script=/ip fire add ena [find address=10.10.10.100 list=gw]
down-script=/ip fire add dis [find address=10.10.10.100 list=gw]
FTP Sheel Script
You should have expect and ftp packages:
| Code: |
| # apt-get install expect ftp |
Then enter the following script and run it:
| Code: |
| #!/usr/bin/expect set timeout 20 log_user 0 # set these variables for your network set router "10.0.11.11" set username "ex" set password "ex" set prompt "ftp> " # filename should be with full path set file "mytestfile" send_user "Opening FTP session to $routern" spawn ftp $router expect -re "Name.*:" send "$usernamer" expect "Password:" send "$passwordr" expect $prompt send "binr" expect $prompt { send_user "Uploading $filen" send "put $filer" } expect "$prompt" { send_user "Exitingn" send "quitr" } sleep 2 send "r" |
Terminal vt102 detected, using multiline input mode
[admin@MikroTik] > /in pr
Flags: X - disabled, D - dynamic, R - running
# NAME TYPE RX-RATE TX-RATE MTU
0 R ether1-intl ether 0 0 1500
1 R ether2-iix ether 0 0 1500
2 R ether3-client ether 0 0 1500
[admin@MikroTik] > /ip ad pr
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK BROADCAST INTERFACE
0 192.168.1.1/24 192.168.1.0 192.168.1.255 ether3-client
1 69.1.1.2/30 69.1.1.0 69.1.1.3 ether1-intl
2 202.65.113.130/28 202.65.113.128 202.65.113.143 ether2-iix
[admin@MikroTik] > /ip ro pr
Flags: X - disabled, A - active, D - dynamic,
C - connect, S - static, r - rip, b - bgp, o - ospf,
B - blackhole, U - unreachable, P - prohibit
# DST-ADDRESS PREF-SRC G GATEWAY DIS INTERFACE
0 A S 0.0.0.0/0 r 69.1.1.1 1 ether1-intl
1 ADC 69.1.1.0/30 69.1.1.2 0 ether1-intl
2 ADC 192.168.1.0/24 192.168.1.1 0 ether3-client
3 ADC 202.65.113.128/28 202.65.113.130 0 ether2-iix
4 A S 202.65.120.250/32 r 202.65.113.129 1 ether2-iix
[admin@MikroTik] > /ip fi nat pr
Flags: X - disabled, I - invalid, D - dynamic
0 chain=srcnat out-interface=ether1-intl action=masquerade
1 chain=srcnat out-interface=ether2-iix action=masquerade
[admin@MikroTik] >
C:Documents and Settingsvalens>tracert www.yahoo.com
Tracing route to www.yahoo-ht2.akadns.net [209.131.36.158]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
2 1 ms <1 ms <1 ms 69.1.1.1
3 1 ms 1 ms 1 ms 202-65-113-41.jogja.citra.net.id [202.65.113.41]
4 1 ms 1 ms 1 ms r47.cr2.jogja.citra.net.id [202.65.112.9]
5 1 ms 2 ms 1 ms r49.cr1.jogja.citra.net.id [202.65.112.1]
6 12 ms 26 ms 13 ms gw.idc.bd1.jkt.citra.net.id [202.65.112.249]
7 18 ms 20 ms 15 ms indosat.openixp.net [218.100.27.166]
8 225 ms 225 ms 225 ms gw-01.indosat.net.id [202.155.27.29]
9 224 ms 225 ms 226 ms ge-0-2-0.distri-04.jkt.ipbb.indosat.net.id [202.155.137.17]
10 * 221 ms 222 ms ge-4-0-0.gw2.jkt.ipbb.indosat.com [202.93.46.212]
11 222 ms 223 ms 223 ms POS1/1.IG2.SAC1.ALTER.NET [157.130.195.13]
12 222 ms 289 ms 222 ms 0.so-1-0-0.XL2.SAC1.ALTER.NET [152.63.54.118]
13 226 ms 242 ms ^C
C:Documents and Settingsvalens>tracert www.cbn.net.id
Tracing route to web.cbn.net.id [210.210.145.202]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
2 1 ms <1 ms 1 ms 202-65-113-129.jogja.citra.net.id [202.65.113.129]
3 1 ms 1 ms 1 ms 202-65-113-41.jogja.citra.net.id [202.65.113.41]
4 1 ms 1 ms 2 ms r47.cr2.jogja.citra.net.id [202.65.112.9]
5 4 ms 1 ms 1 ms gw.noc.cr47-idc.jogja.citra.net.id [202.65.112.125]
6 22 ms 16 ms 11 ms gw.idc.bd1.jkt.citra.net.id [202.65.112.249]
7 12 ms 12 ms 13 ms ^C
C:Documents and Settingsvalens>
[admin@MikroTik] > /rou filter pr
Flags: X - disabled
0 chain=prefix-in prefix-length=0-7 invert-match=no action=discard
1 chain=prefix-in prefix-length=8-24 invert-match=no action=accept set-nexthop=202.65.113.129
2 chain=prefix-in prefix-length=25-32 invert-match=no action=discard
3 chain=prefix-out prefix-length=0-32 invert-match=no action=discard
[admin@MikroTik] > /rou bgp instance pr
Flags: X - disabled
0 name="default" as=64666 router-id=0.0.0.0 redistribute-connected=no redistribute-static=no redistribute-rip=no
redistribute-ospf=no redistribute-other-bgp=no out-filter="" client-to-client-reflection=yes ignore-as-path-len=no
[admin@MikroTik] > /rou bgp peer pr
Flags: X - disabled
0 name="peer1" instance=default remote-address=202.65.120.250 remote-as=64888 tcp-md5-key="" nexthop-choice=default
multihop=yes route-reflect=no hold-time=3m ttl=255 in-filter=prefix-in out-filter=prefix-out
[admin@MikroTik] > /rou bgp peer pr status
Flags: X - disabled
0 name="peer1" instance=default remote-address=202.65.120.250 remote-as=64888 tcp-md5-key="" nexthop-choice=default
multihop=yes route-reflect=no hold-time=3m ttl=255 in-filter=prefix-in out-filter=prefix-out
remote-id=202.65.120.250 uptime=7m21s prefix-count=2784 updates-sent=0 updates-received=2784 withdrawn-sent=0
withdrawn-received=0 remote-hold-time=3m used-hold-time=3m used-keepalive-time=1m refresh-capability=yes
state=established
[admin@MikroTik] > /ip fire mangle pr
Flags: X - disabled, I - invalid, D - dynamic
0 chain=forward out-interface=ether1-intl src-address=192.168.1.2 action=mark-connection new-connection-mark=conn-intl
passthrough=yes
1 chain=forward out-interface=ether2-iix src-address=192.168.1.2 action=mark-connection new-connection-mark=conn-iix
passthrough=yes
2 chain=forward connection-mark=conn-intl action=mark-packet new-packet-mark=packet-intl passthrough=yes
3 chain=forward connection-mark=conn-iix action=mark-packet new-packet-mark=packet-iix passthrough=yes
[admin@MikroTik] > queue tree pr
Flags: X - disabled, I - invalid
0 name="intl-down" parent=ether3-client packet-mark=packet-intl limit-at=0 queue=default priority=8 max-limit=128000
burst-limit=0 burst-threshold=0 burst-time=0s
1 name="intl-up" parent=ether1-intl packet-mark=packet-intl limit-at=0 queue=default priority=8 max-limit=32000
burst-limit=0 burst-threshold=0 burst-time=0s
2 name="iix-up" parent=ether2-iix packet-mark=packet-iix limit-at=0 queue=default priority=8 max-limit=256000
burst-limit=0 burst-threshold=0 burst-time=0s
3 name="iix-down" parent=ether3-client packet-mark=packet-iix limit-at=0 queue=default priority=8 max-limit=1024000
burst-limit=0 burst-threshold=0 burst-time=0s