I am a total novice at scripting and simply duplicated someone elses script (https://wiki.polaire.nl/doku.php?id=rou ... gon_update) but with a small change.
The change I've made is, to instead fetch the complete IP4 bogons list from http://www.team-cymru.org/Services/Bogo ... s-ipv4.txt on a nightly schedule which Team Cymru update every 4hrs or so.
The issue I am having is when I run the modified script and a duplicate IP range is detected in the txt file (which there must be I guess), the script fails and displays "failure: already have such entry" in the Terminal Window.
Can anyone suggest a work around to modify the following script so I can avoid this error and allow the import to continue on?
Ideally if a duplicate entry is found in the txt file and it tries to add it to the "bogons" address list it simply ignores adding it to the address list and moves on to the next line thus continue to import the rest of the bogons in the txt file.
NOTE: The first line in that txt file which is being fetched contains "# last updated 1508907008 (Wed Oct 25 04:50:08 2017 GMT)", would this cause an issue? If so could the first line be ignored?
Code: Select all
## Builds an address list with bogons based on:
## http://www.team-cymru.org/Services/Bogons/fullbogons-ipv4.txt
:log info "Fetching bogon list."
/tool fetch url="http://www.team-cymru.org/Services/Bogons/fullbogons-ipv4.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=fullbogons-ipv4.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)