CentOS的防火墙配置
iptables# 关闭防火墙service iptables stop# 开启对外端口iptables -I INPUT -p tcp --dport 8080 -j ACCEPT# 启动防火墙service iptables start如果iptable不能使用,且报错如下:Redirecting to /bin/systemctl stop iptables.service...
·
iptables
# 关闭防火墙
service iptables stop
# 开启对外端口
iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
# 启动防火墙
service iptables start
如果iptable不能使用,且报错如下:
Redirecting to /bin/systemctl stop iptables.service
Failed to stop iptables.service: Unit iptables.service not loaded.
要么下载,要么换另外的工具:
firewalld # firewall daemon, firewall的守护程序
firewall-cmd # firewalld的命令行工具
systemctl # system control tool,系统控制工具。用户管理服务的启动和停止等。
firewalld
相关命令如下:
# 防火墙(守护程序)的启动,重启和关闭
systemctl start firewalld
systemctl restart firewalld
systemctl stop firewalld
# 查看防火墙运行状态
firewall-cmd --state # 推荐
systemctl status firewalld.service
# 设置防火墙服务的开机自启动
systemctl enable firewalld.service
systemctl disable firewalld.service
# 查看开启的端口列表
firewall-cmd --zone=public --list-ports
firewall-cmd --zone=dmz --list-ports
# dmz(Demilitarized Zone),隔离区,非军事区。
# 加入一个端口到区域。且永久生效。permanent。
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=dmz --add-port=8080/tcp --permanent
# 重载防火墙}更新最新配置
firewall-cmd --reload
firewall-cmd --complete-reload
更多推荐
所有评论(0)