firewalld firewall-cmd 常用命令
网址:https://www.cnblogs.com/klvchen/p/10063875.html
# 开启防火墙 systemctl start firewalld.service # 防火墙开机启动 systemctl enable firewalld.service # 关闭防火墙 systemctl stop firewalld.service # 查看防火墙状态 firewall-cmd --state # 查看现有的规则 iptables -nL firewall-cmd --zone=public --list-ports # 重载防火墙配置 firewall-cmd --reload # 添加单个单端口 firewall-cmd --permanent --zone=public --add-port=81/tcp # 添加多个端口 firewall-cmd --permanent --zone=public --add-port=8080-8083/tcp # 删除某个端口 firewall-cmd --permanent --zone=public --remove-port=81/tcp # 删除 ssh 端口 firewall-cmd --remove-port=22/tcp --permanent firewall-cmd --remove-service=ssh --permanent # 针对某个 IP开放端口 firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="6379" accept" firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.233" accept" # 删除某个IP firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.1.51" accept" # 针对一个ip段访问 firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.0/16" accept" firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="9200" accept" # 添加操作后别忘了执行重载 firewall-cmd --reload # 查看当前起作用的zone firewall-cmd --get-active-zones
Centos 7 systemctl和防火墙firewalld命令
一、防火墙的开启、关闭、禁用命令
(1)设置开机启用防火墙:systemctl enable firewalld.service
(2)设置开机禁用防火墙:systemctl disable firewalld.service
(3)启动防火墙:systemctl start firewalld
(4)关闭防火墙:systemctl stop firewalld
(5)检查防火墙状态:systemctl status firewalld
二、使用firewall-cmd配置端口
(1)查看防火墙状态:firewall-cmd --state
(2)重新加载配置:firewall-cmd --reload
(3)查看开放的端口:firewall-cmd --list-ports
(4)开启防火墙端口:firewall-cmd --zone=public --add-port=9200/tcp --permanent
命令含义:
–zone #作用域
–add-port=9200/tcp #添加端口,格式为:端口/通讯协议
–permanent #永久生效,没有此参数重启后失效
注意:添加端口后,必须用命令firewall-cmd --reload重新加载一遍才会生效
(5)关闭防火墙端口:firewall-cmd --zone=public --remove-port=9200/tcp --permanent
123
标签:--,cmd,防火墙,常用命令,firewall,简记,permanent,linux,port From: https://www.cnblogs.com/xiaobaibailongma/p/17908895.html