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." 
    :do {
           :set lineEnd [:find $content "\n" $lastEnd ] ;
           :set line [:pick $content $lastEnd $lineEnd] ;
           :set lastEnd ( $lineEnd + 1 ) ;
    
           :local tmpArray [:toarray $line] ;
    	:if ( [:pick $tmpArray 0] != "" ) do={
    	:put $tmpArray;
             /ip firewall address-list add name=bogons address=[:pick $tmpArray 0];
    }
    } 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.1429444945.txt.gz · Last modified: 2015/04/19 12:02 by admin