Ben Stienstra

Linux, Unix, network, radio and more...

User Tools

Site Tools


routeros_bogon_update

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." 
    :do {
           :set lineEnd [:find $content "\n" $lastEnd ] ;
           :set line [:pick $content $lastEnd $lineEnd] ;
           :set lastEnd ( $lineEnd + 1 ) ;
    
           :if ( $line != "" ) do={
             /ip firewall address-list add list=bogons address=$line;
           }
    } while ($lineEnd < $contentLen)
  • 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.txt · Last modified: 2015/04/19 12:07 by admin