2

I have a CENTOS Linux VPS. I have the following in my IPTABLES script to run when my VPN restarts, but I get errors when I do a service firewall restart

I've ran each of the commands below manually and they work. According to Host Gator in order for the IPTABLES rules to persist I need to place them in the

/etc/firewall/INCLUDE

file, so I inserted the commands in the file, but the commands that end with ACCEPT or DROP give the errors when I execute the service firewall restart command.

Here is my INCLUDE file:

  1 iptables -A INPUT -p tcp -m tcp --dport 3000 --tcp-flags FIN,SYN,RST,ACK SYN -j ACCEPT
  2 iptables -A INPUT -i lo -j ACCEPT
  3 iptables -A OUTPUT -o lo -j ACCEPT
  4 iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
  5 iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  6 iptables -A INPUT -p tcp --dport 5622  -m state --state NEW -j ACCEPT
  7 iptables -A INPUT -p tcp --dport 80  -m state --state NEW -j ACCEPT
  8 iptables -A INPUT -p tcp --dport 4643  -m state --state NEW -j ACCEPT
  9 iptables -A INPUT -p tcp --dport 22  -m state --state NEW -j ACCEPT
 10 iptables -A INPUT -p ICMP --icmp-type 8 -j ACCEPT
 11 iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 25 -j ACCEPT
 12 iptables -I INPUT -p tcp --dport 3000 --syn -j ACCEPT
 13 iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-ports 3000
 14 iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 3000
 15 iptables -A INPUT -p tcp --tcp-flags ALL NONE -j DROP
 16 iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
 17 iptables -A INPUT -p tcp --tcp-flags ALL ALL -j DROP
 18 iptables -A INPUT -j DROP -p ALL

Errors:

Running file /etc/firewall/INCLUDE
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `ACCEPT
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.
'ptables v1.4.7: Invalid target name `DROP
Try `iptables -h' or 'iptables --help' for more information.

How do I fix the command so they are accepted on when I restart the firewall?

1 Answer 1

3

I think I found the answer already: There are ^M characters after every newline. I believe if I remove them the commands will work. I'm using VIM and if I view them in vim by doing a ':e ++ff=unix' it shows '^M' after every newline.

3
  • That seem to have fixed the errors in my question Aug 12, 2014 at 2:28
  • 1
    see dos2unix command, it will remove them for you.
    – tonioc
    Aug 12, 2014 at 15:12
  • Just found that. Maybe next time. Issue fixed Aug 12, 2014 at 15:33

You must log in to answer this question.

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