LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   iptables script error (https://www.linuxquestions.org/questions/linux-software-2/iptables-script-error-750103/)

muditcse@yahoo.com 08-25-2009 08:39 AM

iptables script error
 
Hi,

I make a script as folows

#!/bin/bash

#mv ReservedUserIP.txt ReservedUserIPList.txt

exec < ReservedUserIPList.txt
IPT="/sbin/iptables"
DIP="172.20.128.88"
while read line
do
echo "I m Reading"
echo $line;
$IPT -I FORWARD 1 -s $line -d $DIP -j ACCEPT
done

errror:

I m Reading
10.203.176.230
' not found.3.5: host/network `10.203.176.230
Try `iptables -h' or 'iptables --help' for more information.

no clue why this error is coming.urgent help needed

TB0ne 08-25-2009 09:11 AM

Quote:

Originally Posted by muditcse@yahoo.com (Post 3656752)
Hi,

I make a script as folows

#!/bin/bash

#mv ReservedUserIP.txt ReservedUserIPList.txt

exec < ReservedUserIPList.txt
IPT="/sbin/iptables"
DIP="172.20.128.88"
while read line
do
echo "I m Reading"
echo $line;
$IPT -I FORWARD 1 -s $line -d $DIP -j ACCEPT
done

errror:

I m Reading
10.203.176.230
' not found.3.5: host/network `10.203.176.230
Try `iptables -h' or 'iptables --help' for more information.

no clue why this error is coming.urgent help needed

Don't flag your posts as urgent, please.

The script line works fine on my system as you have it above, but you don't show us the input text file. Chances are, as the error says, you're getting some bad input, and IPtables is erroring out on it.

fpmurphy 08-25-2009 09:27 AM

The problem is you're confusing iptables by giving it a non-IP address string. Try echoing each line of input with a guard character at each end.
Code:

echo "[$line]"
It this does not show up the problem, try
Code:

cat -vET ReservedUserIPList.txt


All times are GMT -5. The time now is 11:52 AM.