linuxの RedHat , CentOS 7移行ではファイアウォールの設定が 「iptables」から「firewalld」へ変更されています。
systemctl status firewalld
systemctl start firewalld
systemctl stop firewalld
systemctl enable firewalld
firewall-cmd --list-all-zones
デフォルトでは
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0
sources:
services: dhcpv6-client ssh
ports:
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
(active)が付いている public が有効なゾーンです。
設定ファイルの格納場所は
/usr/lib/firewalld/services
/etc/firewalld/services
/etc/firewalld/services の方が優先されるようです。
「http.xml」を 元に 5000番ポーと5001版ポートを開放する 設定ファイル 「kestrel.xml」を作成する
cp /usr/lib/firewalld/services/http.xml /etc/firewalld/services/kestrel.xml
ポートを変更します
vi /etc/firewalld/services/kestrel.xml
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Kestrel</short>
<description>Kestrel port 5001</description>
<port protocol="tcp" port="5001"/>
</service>
ゾーンに作成した Kestrel を追加する
firewall-cmd --add-service=kestrel --permanent
firewall再起動
systemctl reload firewalld
再確認
firewall-cmd --list-all-zones
参考: http://www.eastforest.jp/vps/4539#ICMP-2
※ICMPタイプの一覧表示
firewall-cmd --get-icmptypes
例
address-unreachable
bad-header
communication-prohibited
destination-unreachable
echo-reply
echo-request
fragmentation-needed
host-precedence-violation
host-prohibited
host-redirect
host-unknown
host-unreachable
ip-header-bad
neighbour-advertisement
neighbour-solicitation
network-prohibited
network-redirect
network-unknown
network-unreachable
no-route
packet-too-big
parameter-problem
port-unreachable
precedence-cutoff
protocol-unreachable
redirect
required-option-missing
router-advertisement
router-solicitation
source-quench
source-route-failed
time-exceeded
timestamp-reply
timestamp-request
tos-host-redirect
tos-host-unreachable
tos-network-redirect
tos-network-unreachable
ttl-zero-during-reassembly
ttl-zero-during-transit
unknown-header-type
unknown-option
禁止されているICMPタイプに追加
firewall-cmd --add-icmp-block=echo-request --zone=public
恒久的に禁止されているICMPタイプに追加
firewall-cmd --add-icmp-block=echo-request --zone=public --permanent
禁止されるICMPタイプから削除
firewall-cmd --remove-icmp-block=echo-request
恒久的に禁止されるICMPタイプから削除
firewall-cmd --remove-icmp-block=echo-request --permanent
firewall-cmd --list-rich-rule