centos
防火墙firewalld
参考:
https://blog.csdn.net/s_frozen/article/details/120636667
一. 常规操作
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| yum install firewalld
systemctl status firewalld
service firewall start systemctl start firewalld
service firewall restart firewall-cmd --reload
systemctl stop firewalld.service systemctl stop firewalld
systemctl disable firewalld.service systemctl disable firewalld
service firewall stop systemctl stop firewalld
firewall-cmd --list-ports
firewall-cmd --query-port=80/tcp
firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --permanent --add-port=111/tcp
firewall-cmd --reload
firewall-cmd --zone=public --query-port=80/tcp
firewall-cmd --zone=public --remove-port=80/tcp --permanent
|
二. 防火墙管理服务
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 --in-interface ens16f0 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
firewall-cmd --reload
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
firewall-cmd --zone=work --remove-service=smtp firewall-cmd --permanent --zone=public --remove-service=http
firewall-cmd --list-all
firewall-cmd --list-ports
netstat -ntlp
lsof -i tcp:80
netstat -lnp|grep 8000 ss -ntulp |grep 8000
ps ***
kill -*** kill -9 *** pkill -9 ***(进程名)
firewall-cmd --zone=work --add-service=smtp
firewall-cmd --zone=work --remove-service=smtp firewall http 服务开启 firewall-cmd --query-service http firewall-cmd --add-service=http firewall-cmd --add-service=http --permanent firewall-cmd --reload systemctl reload firewalld firewall https 服务开启
firewall-cmd --query-service https firewall-cmd --add-service=https
|
三. 对单独IP
设置
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.137.139" port protocol="tcp" port="8080" accept"
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.137.139" port protocol="tcp" port="8080" accept"
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="x.x.x.x" accept"
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.137.139" accept"
firewall-cmd --reload
|
效果
注:上面这些基本够用若需要更细致的配置如允许单独IP
特定IP
端口等通过或禁止 见onenote