0

I'm writing an iptables Bash script, and I can't figure out why I get the below error:

Variables

iptables=/sbin/iptables
internet_int=ens33
lan_int=ens37
lan_addr=172.16.30.0/24

Rule

#lan -> internet HTTP (80/tcp)
$iptables -A FORWARD -p TCP -i $lan_int -s $lan_addr --sport 1024:65535 -o $internet_int -m multiport --dports 80,443 -m state --state NEW -j ACCEPT

Problem

Bad argument `172.16.30.0/24'
6
  • That exact command works fine for me. Commented May 26, 2018 at 13:44
  • I get this: root@fw:/home/toor# bash ipt.template start Starting Firewall... Bad argument '172.16.30.0/24' Try `iptables -h' or 'iptables --help' for more information.
    – 91378246
    Commented May 26, 2018 at 13:47
  • i don't know what to say. The syntax looks correct, and indeed works for me. Commented May 26, 2018 at 13:55
  • The only thing I can think of is line termination. Could there be a carriage return and line feed character at the end of the line (dos type) instead of just unix type line termination, line feed? Commented May 26, 2018 at 14:10
  • Nope, double checked it...
    – 91378246
    Commented May 26, 2018 at 14:20

1 Answer 1

0

Had the same issue with a iptables-cmd of my own. I put the variables into parantheses which resovled the issue. Maybe it works for your command too:

"$iptables" -A FORWARD -p TCP -i "$lan_int" -s "$lan_addr" --sport 1024:65535 -o "$internet_int" -m multiport --dports 80,443 -m state --state NEW -j ACCEPT

Haven't tested your command. I assume only the parantheses before the -s argument are required. Maybe give it a try.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .