首页 > 系统 > linux > 正文

centos7防火墙设置
2019-08-23 17:02:30 点击:

针对某个 IP,端口开放 firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192 168 142 166" por
# 针对某个 IP,端口开放 firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="6379" accept"
 
# 针对某个 IP开放 firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" accept"
 
# 删除某个IP firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" 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 --permanent --zone=public --add-port=8080-8083/tcp # 删除某个端口 firewall-cmd --permanent --zone=public --remove-port=81/tcp
 
端口转发
添加(例如3306 -> 3336):
firewall-cmd --permanent --zone=public --add-forward-port=port=3336:proto=tcp:toport=3306:toaddr=
删除:
firewall-cmd --permanent --remove-forward-port=port=3306:proto=tcp:toport=3336:toaddr=
查看转发的端口:firewall-cmd --list-forward-ports

# 添加操作后别忘了执行重载 firewall-cmd --reload
 
 
 
 


相关热词搜索:

上一篇:Linux Root权限 删除文件删除不了
下一篇:composer安装