iptables: unrecognized service

1.查看是否安装防火墙

root@nuoniu-System-Product-Name:/opt# sudo whereis iptables
iptables: /sbin/iptables /usr/share/iptables /usr/share/man/man8/iptables.8.gz

2.新建规则文件

root@nuoniu-System-Product-Name:/opt# mkdir /etc/iptables & vi /etc/iptables/rules.v4
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:syn-flood - [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8950 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8960 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8970 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8800 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9000 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9001 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9100 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9200 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9300 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9400 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9500 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9600 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 9700 -j ACCEPT
-A INPUT -p icmp -m limit --limit 100/sec --limit-burst 100 -j ACCEPT
-A INPUT -p icmp -m limit --limit 1/s --limit-burst 10 -j ACCEPT
-A INPUT -p tcp -m tcp --tcp-flags FIN,SYN,RST,ACK SYN -j syn-flood
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A syn-flood -p tcp -m limit --limit 3/sec --limit-burst 6 -j RETURN
-A syn-flood -j REJECT --reject-with icmp-port-unreachable
COMMIT

3.使防火墙生效

iptables-restore < /etc/iptables/rules.v4

4.创建文件,添加以下内容,使防火墙开机启动

vi /etc/network/if-pre-up.d/iptables
#!/bin/bash
iptables-restore < /etc/iptables/rules.v4

5.添加执行权限

chmod +x /etc/network/if-pre-up.d/iptables

6.查看规则是否生效

iptables -L -n

iptables: unrecognized service_第1张图片

 

你可能感兴趣的:(Ubuntu,iptables)