您的位置:首页 > 运维架构 > Linux

CentOS7将firewalld换成iptables

2015-09-09 14:51 681 查看
CentOS7中用firewalld替代了iptables,默认情况下iptables是没有安装的,如果习惯使用iptables可以将firewalld关掉换成iptables。

1.首先关闭firewalld服务

systemctl stop firewalld
systemctl mask firewalld
systemctl disable firewalld


2.安装iptables

yum -y install iptables


3.配置iptables规则

# Generated by iptables-save v1.4.21 on Thu Sep 10 02:27:20 2015
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -s 127.0.0.1/32 -d 127.0.0.1/32 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 21 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 20 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -p udp -m udp --dport 161 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-port-unreachable
-A FORWARD -j REJECT --reject-with icmp-port-unreachable
-A OUTPUT -j ACCEPT
COMMIT
# Completed on Thu Sep 10 02:27:20 2015


3.开启iptables服务

systemctl enable iptables
systemctl start iptables


4.保存

service iptables save
service iptables restart


5.开机启动

chkconfig iptables on
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: