Ben's notes

Linux, Unix, network, radio...

User Tools

Site Tools


routeros_bogon_update

This is an old revision of the document!


~~TOC~~

RouterOS 6.x - Update bogon list automatically

  • Create a new script:
    /system script add name=bogons
  • Edit new script:
    /system script edit [/system script find name=bogons] source
  • Paste script:
    ## Builds an address list with bogons based on:
    ## http://www.team-cymru.org/Services/Bogons/bogon-bn-agg.txt
    
    :log info "Fetching bogon list." 
    /tool fetch url="http://www.team-cymru.org/Services/Bogons/bogon-bn-agg.txt" mode=http
    
    :log info "Removing all bogons." 
    /ip firewall address-list remove [/ip firewall address-list find list=bogons]
    
    :global content [/file get [/file find name=bogon-bn-agg.txt] contents] ;
    :global contentLen [:len $content];
    
    :global lineEnd 0;
    :global line "";
    :global lastEnd 0;
    
    :log info "Adding bogons from file." 
    :while ($lineEnd < $contentLen) do={
       :set lineEnd [:find $content "\n" $lastEnd];
       :if ([:len $lineEnd] = 0) do={
          :set lineEnd $contentLen;
       }
       :set line [:pick $content $lastEnd $lineEnd];
       :set lastEnd ($lineEnd + 1);
       
       :if ($line != "\n") do={
          /ip firewall address-list add list=bogons address="$line"
       }
    }
  • Test run script:
    /system script run bogons
  • Schedule script:
    /system scheduler add interval=24h start-time=7:00:00 on-event=bogons name=update-bogons
routeros_bogon_update.1429444739.txt.gz · Last modified: 2015/04/19 11:58 by admin