need help with bash scripting
Okay, here's what i'm trying to do, im trying to write a script, so that when i run it with a range of ip adresses, it will block them from being masqueraded. the code i'm using for that is:
Code:
iptables -A FORWARD -s 10.30.20.25 -j DROP |
You can do something like this:
Code:
#!/bin/bash BOT_RANGE: 4 TOP_RANGE: 8 (4) your commands go here (5) your commands go here (6) your commands go here (7) your commands go here (8) your commands go here 2 things: 1) I did not use the hyphen in the range. ie 1.2.3.4 1.2.3.8 vs. 1.2.3.4-1.2.3.8 If you cannot get rid og the hyphen, change the following: Remove these 2 lines: BOT_RANGE="`echo $1 | cut -d. -f4`" TOP_RANGE="`echo $2 | cut -d. -f4`" Replace them with these 4: LOW_RANGE="`echo $1 | cut -d- -f1`" HIG_RANGE="`echo $1 | cut -d- -f2`" BOT_RANGE="`echo ${LOW_RANGE} | cut -d. -f4`" TOP_RANGE="`echo ${HIG_RANGE} | cut -d. -f4`" 2) This only works if only the last field of the ip ranges are different. But I guess you can take it from here to fix that :) |
Since the range is kinda small you could do
"seq 25 46|xargs -iS iptables -A FORWARD -s 10.30.10.S -j DROP" |
All times are GMT -5. The time now is 01:20 AM. |