Skip to content

Instantly share code, notes, and snippets.

@rshipp
Created June 24, 2014 17:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rshipp/8f3fd0131b16a3df00f5 to your computer and use it in GitHub Desktop.
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.
# 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