Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


routeros_bogon_update

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
routeros_bogon_update [2015/04/19 11:58] – [RouterOS 6.x - Update bogon list automatically] adminrouteros_bogon_update [2021/10/30 07:55] admin
Line 1: Line 1:
 {{tag>[security routeros mikrotik bogon bogons]}} {{tag>[security routeros mikrotik bogon bogons]}}
-~~TOC~~ 
  
 =====RouterOS 6.x - Update bogon list automatically===== =====RouterOS 6.x - Update bogon list automatically=====
 +
 +  * Download CA certificates and upload to RouterOS, or with next command (not encrypted by TLS!):<code>/tool fetch url=https://curl.se/ca/cacert.pem</code>
   * Create a new script: <code>/system script add name=bogons</code>   * Create a new script: <code>/system script add name=bogons</code>
   * Edit new script:<code>/system script edit [/system script find name=bogons] source</code>   * Edit new script:<code>/system script edit [/system script find name=bogons] source</code>
Line 22: Line 23:
  
 :log info "Adding bogons from file."  :log info "Adding bogons from file." 
-:while ($lineEnd < $contentLen) do=+:do { 
-   :set lineEnd [:find $content "\n" $lastEnd]; +       :set lineEnd [:find $content "\n" $lastEnd ] ; 
-   :if ([:len $lineEnd] = 0) do={ +       :set line [:pick $content $lastEnd $lineEnd] ; 
-      :set lineEnd $contentLen; +       :set lastEnd ( $lineEnd + 1 ) ; 
-   } + 
-   :set line [:pick $content $lastEnd $lineEnd]; +       :if ( $line != "" ) do={ 
-   :set lastEnd ($lineEnd + 1); +         /ip firewall address-list add list=bogons address=$line; 
-    +       
-   :if ($line != "\n") do={ +while ($lineEnd < $contentLen)</code>
-      /ip firewall address-list add list=bogons address="$line" +
-   +
-}</code>+
   * Test run script:<code>/system script run bogons</code>   * Test run script:<code>/system script run bogons</code>
   * Schedule script:<code>/system scheduler add interval=24h start-time=7:00:00 on-event=bogons name=update-bogons</code>   * Schedule script:<code>/system scheduler add interval=24h start-time=7:00:00 on-event=bogons name=update-bogons</code>
  
routeros_bogon_update.txt · Last modified: 2021/10/31 14:40 by admin