Linux防火墙操作端口命令

原文:Linux防火墙添加端口_小轱辘.的博客-CSDN博客_linux防火墙添加端口

低版本:CenOS6.5 以下 至 RedHad6.5以下

service iptables status   // 查看防火墙状态
iptables -L -n     // 使用命令查看端口开启情况
iptables -F        // 清除预设表filter中的所有规则链的规则
iptables -X        // 清除预设表filter中使用者自定链中的规则
/etc/rc.d/init.d/iptables save   // 保存以后下次重启才会开启
service iptables restart        // 重启一下防火墙
 
 
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --dport 80 -j ACCEPT
 
/etc/rc.d/init.d/iptables save
 
service iptables restart        // 重启一下防火墙
 
iptables -D INPUT -p tcp --dport 443 -j ACCEPT
iptables -D OUTPUT -p tcp --dport 443 -j ACCEPT
iptables -L -n
/etc/rc.d/init.d/iptables save
service iptables restart        // 重启一下防火墙 

高版本:CenOS6.5 以上 至 RedHad6.5以上

systemctl status firewalld    // 查看firewall服务状态
firewall-cmd --state          // 查看firewall状态
service firewalld start       // 开启firewall服务状态
 
firewall-cmd --query-port=80/tcp      // 查询端口是否开放
firewall-cmd --permanent --add-port=80/tcp     // 开放80端口
firewall-cmd --permanent --remove-port=80/tcp  // 移除端口
 
firewall-cmd --permanent --list-ports // 查看防火墙的开放的端口
firewall-cmd --list-all   //查看防火墙规则


firewall-cmd --reload         // 做完对防火墙的操作以后要重启防火墙
 

注:service firewalld stop 为本次生效、重启服务器后失效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值