标签:
yum install firewalld
$ firewall-cmd -V | --version
$ firewall-cmd -h | --help
$ firewall-cmd -q | --quiet
$ firewall-cmd --state running
$ firewall-cmd --reload
$ firewall-cmd --complete-reload
$ firewall-cmd --permanent
$ firewall-cmd --get-default-zone public
本机的默认区域是public
$ firewall-cmd --set-default-zone=zone
$ firewall-cmd --get-active-zone public interfaces: eno16777736
$ firewall-cmd --get-services RH-Satellite-6 amanda-client bacula bacula-client dhcp dhcpv6 dhcpv6-client dns freeipa-ldap freeipa-ldaps freeipa-replication ftp high-availability http https imaps ipp ipp-client ipsec iscsi-target kerberos kpasswd ldap ldaps libvirt libvirt-tls mdns mountd ms-wbt mysql nfs ntp openvpn pmcd pmproxy pmwebapi pmwebapis pop3s postgresql proxy-dhcp radius rpc-bind rsyncd samba samba-client smtp ssh telnet tftp tftp-client transmission-client vdsm vnc-server wbem-https
$ firewall-cmd --get-icmptypes destination-unreachable echo-reply echo-request parameter-problem redirect router-advertisement router-solicitation source-quench time-exceeded
可以看到现在firewalld默认支持的服务已经非常多了
$ firewall-cmd --list-all-zones
$ firewall-cmd --zone=zone --list-all
查看指定接口所属区域
$ firewall-cmd --get-zone-of-interface=eth0
$ firewall-cmd --zone=zone --add-interface=<interface>
$ firewall-cmd --zone=zone --change-interface=<interface>
$ firewall-cmd --zone=zone --remove-interface=<interface>
查询某个区域中是否包含这个接口
$ firewall-cmd --zone=zone --query-interface=<interface>
$ firewall-cmd --zone=zone --list-services
$ firewall-cmd --panic-on
$ firewall-cmd --panic-off
查看是否启用应急模式
$ firewall-cmd --query-panic
$ firewall-cmd [--permanet] --zone=zone --add-service [--timeout=seconds]
$ firewall-cmd --zone=public --add-service --timeout=300
$ firewall-cmd --zone=zone --remove-service
$ firewall-cmd --zone=zone --query-service
$ firewall-cmd --zone=zone --add-port=<port>/protocol [--timeout=seconds]
$ firewall-cmd --zone=zone --remove-port=<port>[-<port>]/<protocol>
$ firewall-cmd --zone=zone --query-port=<port>[-<port>]/<protocol>
$ firewall-cmd --zone=zone --add-masquerade
$ firewall-cmd --zone=zone --remove-masquerade
查询区域的伪装状态
$ firewall-cmd --zone=zone --query-masquerade
$ firewall-cmd --zone=zone --add-icmp-block=<icmptype>
$ firewall-cmd --zone=zone --remove-icmp-block=<icmptype>
$ firewall-cmd --zone=zone --query-icmp-block=<icmptype>
$ firewall-cmd --zone=public --add-icmp-block=echo-reply
$ firewall-cmd --zone=zone --add-forward-port=port=<port>-[<port>]:proto=<protocol> {:toport=<port>-[<port>] | :toaddr=<address> | :toport=<port>-[<port>]:toaddr=<address>}
端口映射到另外一个端口,端口映射到另外一个地址上的相同端口,端口映射到另外一台主机上的不同端口,仅限于ipv4使用;
将本机的80端口转发到8080端口 $ firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=8080
将本机的80端口转发到后端192.168.1.249主机的80端口上 $ firewall-cmd --zone=public --add-forward-port=port=80:proto=tcp:toport=80:toaddr=192.168.1.249 success
$ firewall-cmd --zone=zone --remove-forward-port=port=<port>-[<port>]:proto=<protocol> {:toport=<port>-[<port>] | :toaddr=<address> | :toport=<port>-[<port>]:toaddr=<address>}
移除本机80到8080端口的转发 $ firewall-cmd --zone=public --remove-forward-port=port=80:proto=tcp:toport=8080
移除本机80端口到后端主机192.168.1.249的80端口的映射 $ firewall-cmd --zone=public --remove-forward-port=port=80:proto=tcp:toport=80:toaddr=192.168.1.249
$ firewall-cmd --zone=zone --query-forward-port=port=<port>-[<port>]:proto=<protocol> {:toport=<port>-[<port>] | :toaddr=<address> | :toport=<port>-[<port>]:toaddr=<address>}
$ firewall-cmd --permanent --get-services
$ firewall-cmd --permanent --get-icmptypes
$ firewall-cmd --permanent --get-zones
$ firewall-cmd --direct --passthrough { ipv4 | ipv6 | eb } <args>
$ firewall-cmd --direct --add-chain { ipv4 | ipv6 | eb } <table> <chain>
$ firewall-cmd --direct --remove-chain { ipv4 | ipv6 | eb } <table> <chain>
$ firewall-cmd --direct --query-chain { ipv4 | ipv6 | eb } <table> <chain>
$ firewall-cmd --direct --get-chains { ipv4 | ipv6 | eb } <table>
$ firewall-cmd --direct --add-rule { ipv4 | ipv6 | eb } <table> <chain> <priority> <args>
$ firewall-cmd --direct --remove-rule { ipv4 | ipv6 | eb } <table> <chain> <args>
$ firewall-cmd --direct --query-rule { ipv4 | ipv6 | eb } <table> <chain> <args>
$ firewall-cmd --direct --get-rules { ipv4 | ipv6 | eb } <table> <chain>
标签:
原文地址:http://www.cnblogs.com/hf9999/p/5594384.html