本文共 1544 字,大约阅读时间需要 5 分钟。
CentOS7 的防火墙配置与之前版本存在显著差异,主要使用 firewall
替代了之前的 iptables
。以下将详细介绍 CentOS7 下的防火墙配置方法。
service iptables status
service iptables stop
service iptables start
service iptables restart
####永久关闭防火墙
chkconfig iptables off
chkconfig iptables on
vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
service iptables restart
systemctl status firewalld
active (running)
则表示 firewall 服务已启动。inactive (dead)
则表示 firewall 服务已停止。firewall-cmd --state
service firewalld start
service firewalld restart
service firewalld stop
systemctl disable firewalld
firewall-cmd --list-all
firewall-cmd --query-port=8080/tcp
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --remove-port=8080/tcp
firewall-cmd --reload
--permanent
:表示设置为持久有效。--add-port
:用于添加指定端口。--remove-port
:用于移除指定端口。--query-port
:用于查询指定端口状态。systemctl stop firewalldsystemctl disable firewalld
yum install iptables-services
vim /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport [端口号] -j ACCEPT
systemctl restart iptables.service
systemctl enable iptables.service
转载地址:http://knyj.baihongyu.com/