网硕互联技术交流社区

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1928|回复: 0

Centos7 替换防火墙为iptables

[复制链接]

4

主题

4

帖子

42

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
42
发表于 2018-11-22 17:06:15 | 显示全部楼层 |阅读模式
关闭firewall
#停止firewall
  1. systemctl stop firewalld.service
复制代码

#禁止firewall开机启动
  1. systemctl disable firewalld.service
复制代码

②安装iptables防火墙
#安装iptables
  1. yum install -y iptables-services
复制代码

#编辑防火墙文件
  1. vi /etc/sysconfig/iptables
复制代码

添加80和3306、161端口
  1. -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
  2. -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
  3. -A INPUT -m state –state NEW -m udp -p udp –dport 161 -j ACCEPT
复制代码

#重启防火墙使配置文件生效
  1. systemctl restart iptables.service
复制代码

#设置iptables防火墙为开机启动项
  1. systemctl enable iptables.service
复制代码

③关闭SELINUX
 
  1. vi /etc/selinux/config
复制代码

 修改以下配置
 
  1. SELINUX=enforcing
  2. 修改为:
  3. SELINUX=disabled
复制代码


 #使配置立即生效
 setenforce 0


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|网硕互联技术交流社区

GMT+8, 2024-4-20 20:29 , Processed in 0.219207 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表