Created
June 24, 2014 17:59
-
-
Save rshipp/8f3fd0131b16a3df00f5 to your computer and use it in GitHub Desktop.
Convert a file with one IP on each line into a script that can be copy-pasted into a SonicWALL shell to create a new address group.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# IP List to Address Group | |
# Convert a file with one IP on each line into a script that can be | |
# copy-pasted into a SonicWall shell to create a new address group. | |
# Use it like `./iplist2addressgroup.sh iplist.txt > script.txt`. | |
# I used it to bulk-blasklist some public IPs. | |
# See https://www.fuzeqna.com/sonicwallkb/ext/kbdetail.aspx?kbid=10896 | |
# Config | |
objname='blacklistedip' | |
groupname='Blacklist' | |
zone='WAN' | |
# Script | |
file="$1" | |
number=0 | |
objs=( ) | |
for address in $(cat "${file}"); do | |
echo "address-object ${objname}${number}" | |
echo "zone ${zone}" | |
echo "host ${address}" | |
echo "exit" | |
echo "" | |
objs+=("${objname}${number}") | |
((number+=1)) | |
done | |
echo "address-group ${groupname}" | |
for obj in ${objs[@]}; do | |
echo "address-object ${obj}" | |
done | |
echo "" | |
echo "finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment