九月 01

正常的狀況下,RouterOS會自動管理系統上的IP位置。

像是使用VPN撥接上ROS後,ROS系統會自動給予1個IP位置,斷線後該IP位置會自動刪除。

但有的時候,撥接上來的VPN發生異常斷線後,該IP並沒有自動刪除。

這時就會導致該帳號永遠無法再撥接上來(帳號使用固定VPN IP)

為了解決這狀況,所以需要一個小Script搭配Scheduler來自動刪除ROS上這些無效的IP位置

Script內容如下

#Script TestOS:RouterOS 5.6
#Date:2011/09/01
#Script Description:刪除無效的IP位置

# 把無效的IP位置資料全部讀出來
:foreach i in=[/ip address find invalid=yes] do={
#刪除無效的IP
    /ip address remove $i
}

.
.
懶人包如下,於winbox中開啟Terminal,貼上下面的指令
系統會完成新增上面的Script並每5分鐘於Scheduler中自動執行1次

/system script
add name=DeleteInvalidIP policy=\
    ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api source="#Script T\
    estOS:RouterOS 5.6\r\
    \n#Date:2011/09/01\r\
    \n#Script Description:\A7R\B0\A3\B5L\AE\C4\AA\BAIP\A6\EC\B8m\r\
    \n\r\
    \n# \A7\E2\B5L\AE\C4\AA\BAIP\A6\EC\B8m\B8\EA\AE\C6\A5\FE\B3\A1\C5\AA\A5X\A8\D3\r\
    \n:foreach i in=[/ip address find invalid=yes] do={\r\
    \n#\A7R\B0\A3\B5L\AE\C4\AA\BAIP\r\
    \n    /ip address remove \$i  \r\
    \n}"

/system scheduler
add disabled=no interval=5m name=AutoDeleteIP on-event=\
    "/system script run DeleteInvalidIP" policy=\
    ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api start-date=\
    aug/19/2011 start-time=02:08:36

One Response to “自動刪除RouterOS上無效的IP位置”

  1. Automatically deleted RouterOS on invalid IP position | Technical News Says:

    […] / System scriptadd name = DeleteInvalidIP policy =     ftp, reboot, read, write, policy, test, winbox, password, sniff, sensitive, api source = "# Script T     estOS: RouterOS 5.6 r      N # Date: 2011/09/01 r      N # Script Description: A7R B0 A3 B5L AE C4 AA BAIP A6 EC B8m r      N r      N # A7 E2 B5L AE C4 AA BAIP A6 EC B8m B8 EA AE C6 A5 FE B3 A1 C5 AA A5X A8 D3 r      N: foreach i in = [/ip address find invalid = yes] do = { r      N # A7R B0 A3 B5L AE C4 AA BAIP r      N / ip address remove $ i r      N} "/ System scheduleradd disabled = no interval = 5m name = AutoDeleteIP on-event =     "/ System script run DeleteInvalidIP" policy =     ftp, reboot, read, write, policy, test, winbox, password, sniff, sensitive, api start-date =     aug/19/2011 start-time = 02:08:36 the computer tea bags Blog […]

留下評論

限制時效已用盡。請重新載入驗證碼。