У меня CENTOS Linux VPS. У меня есть следующий сценарий IPTABLES, который запускается при перезапуске VPN, но при выполнении service firewall restart
Я запускал каждую из приведенных ниже команд вручную, и они работают. Согласно Host Gator, чтобы правила IPTABLES сохранялись, мне нужно поместить их в
/etc/firewall/INCLUDE
файла, поэтому я вставил команды в файл, но команды, заканчивающиеся на ACCEPT или DROP, выдают ошибки, когда я выполняю service firewall restart
команда.
Вот мой файл INCLUDE:
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
Ошибки:
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.
Как мне исправить команды, чтобы они принимались при перезапуске брандмауэра?
Думаю, я уже нашел ответ: после каждой новой строки есть символы ^ M. Я считаю, что если я их удалю, команды будут работать. Я использую VIM, и если я просматриваю их в vim, выполняя ': e ++ ff = unix', он показывает '^ M' после каждой новой строки.