Reputation: 251
I use a simple shell script to block IP addresses that just substitutes my input (an IP) for a variable in an iptables, IPFW, etc. (depending on which platform on) command, but they all basically follow this format:
read -p "IP to Block: " ip
ipfw add deny ip from $ip to any
Is it possible to simply execute, sequentially, a group of user-defined variables. For example, three IP addresses, and have the script execute, basically, three times for each of the variables, but limit my input to a single prompt (being asked to input one time)?
Upvotes: 2
Views: 343
Reputation: 191819
Sounds like you want to do something like this:
for ip in $@; do
ipfw add deny ip from $ip to any
done
I'm not sure if that's the exact usage of ipfw
, but $@
is every word in a command except the first, so it would work with:
your-script-name 1.2.3.4 1.3.4.5 1.4.5.6
Upvotes: 1