このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
|
centos:firewall-cmd [2020/06/01 16:04] y2sunlight |
centos:firewall-cmd [2020/06/02 08:03] (現在) y2sunlight |
||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | > 編集中 | ||
| - | |||
| ====== firewall-cmdコマンド ====== | ====== firewall-cmdコマンド ====== | ||
| Version CentOS 7.2 | Version CentOS 7.2 | ||
| 行 18: | 行 16: | ||
| * [[centos: | * [[centos: | ||
| * [[centos: | * [[centos: | ||
| - | * [[centos: | + | * firewall-cmd --- ファイアウォールの操作 |
| リンク | リンク | ||
| 行 25: | 行 23: | ||
| ---- | ---- | ||
| - | ===== ゾーン ===== | + | ===== firewall-cmdの基礎知識 ===== |
| + | |||
| + | ==== ゾーン ==== | ||
| + | |||
| + | ファイアウォールは、ゾーン毎に設定を行います。そして、インターフェース(NIC)に対してそのゾーンを割り当てます。結果として各ゾーンは複数のインターフェースを持つことになります。事前定義されたゾーンは ''/ | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --get-active-zones | ||
| + | |||
| + | public | ||
| + | interfaces: eth0 | ||
| + | </ | ||
| + | |||
| + | ゾーンの割り当てのないインターフェースには、デフォルトゾーンが割り当てられます。以下のコマンドは、デフォルトゾーンを表示します。 | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --get-default-zone | ||
| + | |||
| + | public | ||
| + | </ | ||
| + | |||
| + | 本章では、publicゾーンがデフォルトになっている場合を仮定します。 | ||
| + | |||
| + | ==== サービス ==== | ||
| + | |||
| + | サービスを使用すると、ポートのオープン、プロトコルの定義、パケット転送などを一括して行う事ができます。ゾーンにサービスを追加することで、そのサービス用のファイアウォール設定が反映されます。各サービスのファイアウォール設定は ''/ | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | 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のユースケース ===== | ||
| + | |||
| + | 以下の例は、publicゾーンを対象とした場合を想定しています。他のゾーンを指定する場合は、'' | ||
| + | |||
| + | === サービスの許可 === | ||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --list-service | ||
| + | </ | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --add-service=http | ||
| + | firewall-cmd --add-service=http --permanent | ||
| + | |||
| + | # | ||
| + | firewall-cmd --reload | ||
| + | </ | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --remove-service=http | ||
| + | firewall-cmd --remove-service=http --permanent | ||
| + | |||
| + | firewall-cmd --reload | ||
| + | </ | ||
| + | |||
| + | === ポート番号の許可 === | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --list-ports | ||
| + | </ | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --add-port=8080/ | ||
| + | firewall-cmd --add-port=8080/ | ||
| + | |||
| + | # | ||
| + | firewall-cmd --reload | ||
| + | </ | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --remove-port=8080/ | ||
| + | firewall-cmd --remove-port=8080/ | ||
| + | |||
| + | firewall-cmd --reload | ||
| + | </ | ||
| + | |||
| + | === IPアドレスの許可 === | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --list-sources | ||
| + | </ | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --add-source=192.168.1.0/ | ||
| + | firewall-cmd --add-source=192.168.1.0/ | ||
| + | |||
| + | firewall-cmd --reload | ||
| + | </ | ||
| + | |||
| + | {{fa> | ||
| + | < | ||
| + | firewall-cmd --remove-source=192.168.1.0/ | ||
| + | firewall-cmd --remove-source=192.168.1.0/ | ||
| + | |||
| + | firewall-cmd --reload | ||
| + | </ | ||
| + | |||
| + | \\ | ||
| + | |||