当前位置:   article > 正文

firewalld_firewallapi.dll

firewallapi.dll

#####1.firewalld开启#################

[root@localhost Desktop]# systemctl stop iptables.service

[root@localhost Desktop]# systemctl disable iptables.service

[root@localhost Desktop]# systemctl mask iptables.service

[root@localhost Desktop]# systemctl unmask firewalld.service

[root@localhost Desktop]# systemctl start firewalld

[root@localhost Desktop]# systemctl status firewalld

#####2.关于firewalld的域#################

[root@localhost Desktop]# firewall-cmd --get-zones    ##查看所有域

trusted接受所有网络连接
home用于家庭网络,允许接受ssh mdns ipp-client samba-client dhcp-client
work工作网络ssh ipp-client dhcp-client
public公共网络ssh dhcp-client
dmz

军级网络ssh

block拒绝所有
drop丢弃  所有数据全部丢弃无任何回复
internal内部网络ssh mdns ipp-client samba-client dhcp-client
externalipv4网络地址伪装转发 sshd

 

 

 

 

 

 

 

 

 

#####3.关于firewalld的设定原理及数据存储#################

/etc/firewalld       ##火墙配置目录

/lib/firewalld        ##火墙模块目录

#####4.关于firewalld的命令#################

[root@localhost Desktop]# firewall-cmd --state   ##查看火墙状态

[root@localhost Desktop]# firewall-cmd --get-zones    ##查看所有域

[root@localhost Desktop]# firewall-cmd --get-active-zones    ##查看火墙中生效的域

[root@localhost Desktop]# firewall-cmd --get-default-zone    ##查看默认域

[root@localhost Desktop]# firewall-cmd --list-all    ##查看默认域中的火墙策略

[root@localhost Desktop]# firewall-cmd --list-all --zone=work    ##查看指定域的火墙策略

[root@localhost ~]# firewall-cmd --set-default-zone=trusted    ##设定默认域

[root@localhost ~]# firewall-cmd --get-services   ##查看所有可设定的服务

[root@localhost ~]# firewall-cmd --permanent --remove-service=cockpit   ##移除服务

[root@localhost ~]# firewall-cmd --reload    ##刷新

[root@localhost ~]# firewall-cmd --permanent --add-source=172.25.254.0/24 --zone=block    ##指定数据来源访问指定域

[root@localhost ~]# firewall-cmd --permanent --remove-source=172.25.254.0/24 --zone=block    ##删除自定域中的数据来源

[root@localhost ~]# firewall-cmd --permanent --remove-interface=ens224 --zone=public    ##删除指定域的网络接口

[root@localhost ~]# firewall-cmd --permanent --add-interface=ens224 --zone=block     ##添加指定域的网络接口

[root@localhost ~]# firewall-cmd --permanent --change-interface=ens224 --zone=public       ##更改网络接口到指定域

#####5.firewalld的高级规则##################

[root@localhost ~]# firewall-cmd --direct --add-rule ipv4 filter INPUT 1 -s 172.25.254.0/24 -p tcp --dport 22 -j ACCEPT

[root@localhost ~]# firewall-cmd --direct --get-all-rules    ##查看高级规则

 

测试:

[root@test Desktop]# ssh root@172.25.254.110  ##可访问

#####6.firewalld中的NAT##################

SNAT:

[root@localhost ~]# firewall-cmd --permanent --add-masquerade

[root@localhost ~]# firewall-cmd --reload

测试:

[root@test Desktop]# ping 192.168.3.110

DNAT:

[root@localhost ~]# firewall-cmd --permanent --add-forward-port=port=22:proto=tcp:toaddr=172.25.254.120

[root@localhost ~]# firewall-cmd --reload

测试:

[root@rhel7 ~]# ssh root@192.168.3.110

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/669669
推荐阅读
相关标签
  

闽ICP备14008679号