1、关闭 CentOS 7 自带的 firewall 防火墙


# 关闭防火墙

# 取消开机启动

systemctl stop firewalld

systemctl disable firewalld

2、安装 iptables-services


# Cetnos 7 默认已经装了 iptables, 只需装 services

yum install iptables-services -y

3.首先开放22端口以防止ssh掉线

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT

 

保存配置防止丢失

service iptables save

默认设置为拒绝

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

 


                                                     
                     

作者 admin

发表评论

您的电子邮箱地址不会被公开。