I'm trying to insert multiple new lines of text into an iptables script using sed in a while loop. I'm not sure if this is the most effective way. Searching the forums has helped me come up with a good beginning but it's not 100%. I'd like it to search out a unique line in my current iptables file and add new rules above it. The problem now is that it only ends up inserting one new line instead of the 20 it should (based on the $BOGON_LIST).
while read bogonline ;do
sed '/--state ESTABLISHED,RELATED -j ACCEPT/ i\-A RH-Firewall-1-INPUT -s '"${bogonline}"' -j DROP' $IPT_SCRIPT > new_iptables
done < $BOGON_LIST
The $BOGON_LIST is a file with ip addresses on a line by themselves like so:
IP
IP
IP