1、iptables
1)查看是否安装iptables
rpm -qa | grep iptables
2)查看是否启动iptables
systemctl status iptables.service
3)启动iptables
systemctl start iptables.service
4)临时禁用一个端口,禁掉8002端口,无需重启iptables
iptables -I INPUT -p tcp --dport 8002 -j DROP
清掉临时规则,执行完这一句8002端口又能访问了,无需重启iptables
iptables -F
2、firewall
1)查看firewall状态:
systemctl status firewalld
2)关闭firewall:
systemctl stop firewalld
3)开启firewall:
systemctl start firewalld
4)开放端口
firewall-cmd --zone=public --add-port=5672/tcp --permanent
5)关闭端口
firewall-cmd --zone=public --remove-port=5672/tcp --permanent
6)使设置立即生效
firewall-cmd --reload
7)查看所有开放的端口
firewall-cmd --zone=public --list-ports
8)查看某端口是否开启
firewall-cmd --query-port=5672/tcp