赞
踩
#####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 |
external | ipv4网络地址伪装转发 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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。