• 欢迎访问爱玩吧
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏爱玩吧

[教程]CentOS 7使用iptables开放设置端口

实用教程 aiwanyule 3年前 (2021-05-12) 已收录

说明:CentOS 7默认使用的是firewall作为防火墙,使用iptables必须重新安装设置一下。如果不想太麻烦可参考:CentOS 7开放设置端口及firewall常用命令介绍
1、直接关闭防火墙

systemctl stop firewalld.service           #停止firewall
systemctl disable firewalld.service        #禁止firewall开机启动

2、安装并设置iptables service

yum -y install iptables-services

如果要修改防火墙配置,如增加防火墙端口3306

vi /etc/sysconfig/iptables

增加规则

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service  #设置防火墙开机启动

最后重启系统使设置生效即可。

更多有关iptables使用请看:Linux防火墙iptables基本应用


爱玩吧 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:[教程]CentOS 7使用iptables开放设置端口
喜欢 (0)