CentOS-7ファイアウォールコマンド
14222 ワード
义齿
Firewalldベースコマンド
: systemctl start firewalld
:systemctl status firewalld
: systemctl disable firewalld
: systemctl stop firewalld
:systemctl enable firewalld.service
:systemctl disable firewalld.service
:systemctl is-enabled firewalld.service
:systemctl list-unit-files|grep enabled
:systemctl --failed
firewalld構成cmd
: firewall-cmd --version
: firewall-cmd --help
: firewall-cmd --state
: firewall-cmd --zone=public --list-ports
: firewall-cmd --reload
: firewall-cmd --get-active-zones
: firewall-cmd --get-zone-of-interface=eth0
:firewall-cmd --panic-on
: firewall-cmd --panic-off
: firewall-cmd --query-panic
firewalld構成cmd
firewall-cmd --zone=public( ) --add-port=80/tcp( ) --permanent( )
firewall-cmd --zone=public --add-service=http --permanent
//
firewall-cmd --reload
//
firewall-cmd --zone= public --query-port=80/tcp
//
firewall-cmd --zone= public --remove-port=80/tcp --permanent
firewall-cmd --list-services
firewall-cmd --get-services
firewall-cmd --add-service=<service>
firewall-cmd --delete-service=<service>
/* /etc/firewalld/zones/public.xml ,
* , , , 。
*/
firewall-cmd --zone=public --query-port=80/tcp
firewall-cmd --zone=public --query-port=8080/tcp
firewall-cmd --zone=public --query-port=3306/tcp
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --zone=public --add-port=3306/tcp --permanent
firewall-cmd --zone=public --query-port=3306/tcp
firewall-cmd --zone=public --query-port=8080/tcp
//
firewall-cmd --reload
firewall-cmd --zone=public --query-port=3306/tcp
firewall-cmd --zone=public --query-port=8080/tcp
コマンド詳細
//
–add-service
//
–zone
// , : /
–add-port=80/tcp
// ,
–permanent
使用の詳細
// ip
firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="192.168.0.4/24" service name="http" accept'
//
firewall-cmd --permanent --zone=public --remove-rich-rule='rule family="ipv4" source address="192.168.0.4/24" service name="http" accept'
// ip
firewall-cmd --permanent --add-rich-rule 'rule family=ipv4 source address=192.168.0.1/2 port port=80 protocol=tcp accept'
//
firewall-cmd --permanent --remove-rich-rule 'rule family=ipv4 source address=192.168.0.1/2 port port=80 protocol=tcp accept' //
// IP
firewall-cmd --query-masquerade
// IP
firewall-cmd --add-masquerade
// IP
firewall-cmd --remove-masquerade
// 80 8080
firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080
// 80 192.168.0.1
firewall-cmd --add-forward-port=proto=80:proto=tcp:toaddr=192.168.1.0.1
// 80 192.168.0.1 8080
firewall-cmd --add-forward-port=proto=80:proto=tcp:toaddr=192.168.0.1:toport=8080