差分
このページの2つのバージョン間の差分を表示します。
| 両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
| linux:commands:network:firewall-cmd [2021/11/25 23:24] – ともやん | linux:commands:network:firewall-cmd [2025/02/21 12:16] (現在) – [サービスで許可されるポートを調べる] ともやん | ||
|---|---|---|---|
| 行 1: | 行 1: | ||
| - | ====== firewalld(Fedora) ====== | + | ====== firewalld (Linux) ====== |
| firewall-cmd は firewalld パッケージに含まれている。 | firewall-cmd は firewalld パッケージに含まれている。 | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo dnf install firewalld | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| + | </pre></ | ||
| + | </WRAP> | ||
| - | ===== 定義済みゾーンの確認 ===== | + | ===== 定義済みゾーンの確認 |
| - | < | + | Fedora 36\\ |
| - | <code> | + | < |
| - | $ firewall-cmd --get-zones | + | <WRAP color_command>< |
| - | FedoraServer FedoraWorkstation block dmz drop external home internal public trusted work | + | <font color="# |
| - | </code> | + | </ |
| + | <WRAP color_result>< | ||
| + | FedoraServer FedoraWorkstation block dmz drop external home internal | ||
| + | </pre></ | ||
| </ | </ | ||
| - | ===== デフォルトゾーンの確認 ===== | + | <WRAP color_term> |
| - | <code> | + | <WRAP color_command>< |
| - | $ firewall-cmd --get-default-zone | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result_long>< | ||
| + | FedoraServer | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: cockpit dhcpv6-client ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | FedoraWorkstation (active) | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: wlp2s0 | ||
| + | sources: | ||
| + | services: dhcpv6-client mdns samba-client ssh vnc-server | ||
| + | ports: 1025-65535/ | ||
| + | protocols: | ||
| + | forward: no | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | block | ||
| + | target: %%REJECT%% | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | dmz | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | drop | ||
| + | target: DROP | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | external | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: yes | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | home | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcpv6-client mdns samba-client ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | internal | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcpv6-client mdns samba-client ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | libvirt | ||
| + | target: ACCEPT | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcp dhcpv6 dns ssh tftp | ||
| + | ports: | ||
| + | protocols: icmp ipv6-icmp | ||
| + | forward: no | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | rule priority=" | ||
| + | |||
| + | nm-shared | ||
| + | target: ACCEPT | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcp dns ssh | ||
| + | ports: | ||
| + | protocols: icmp ipv6-icmp | ||
| + | forward: no | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | rule priority=" | ||
| + | |||
| + | public | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcpv6-client mdns ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | trusted | ||
| + | target: ACCEPT | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | work | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcpv6-client mdns ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | |||
| + | Ubuntu 22.04.1 LTS\\ | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | block dmz drop external home internal nm-shared public trusted work | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result_long>< | ||
| + | block | ||
| + | target: %%REJECT%% | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | dmz | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | drop | ||
| + | target: DROP | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | external | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: yes | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | home | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcpv6-client mdns samba-client ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | internal | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcpv6-client mdns samba-client ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | nm-shared | ||
| + | target: ACCEPT | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcp dns ssh | ||
| + | ports: | ||
| + | protocols: icmp ipv6-icmp | ||
| + | forward: no | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | rule priority=" | ||
| + | |||
| + | public (active) | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: enp1s0 | ||
| + | sources: | ||
| + | services: dhcpv6-client ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | trusted | ||
| + | target: ACCEPT | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | work | ||
| + | target: default | ||
| + | icmp-block-inversion: | ||
| + | interfaces: | ||
| + | sources: | ||
| + | services: dhcpv6-client ssh | ||
| + | ports: | ||
| + | protocols: | ||
| + | forward: yes | ||
| + | masquerade: no | ||
| + | forward-ports: | ||
| + | source-ports: | ||
| + | icmp-blocks: | ||
| + | rich rules: | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== デフォルトゾーンとアクティブゾーンの確認 ===== | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| FedoraWorkstation | FedoraWorkstation | ||
| - | </code> | + | </pre></ |
| + | </WRAP> | ||
| - | < | + | < |
| - | < | + | <WRAP color_command> |
| - | はじめにデフォルトゾーンの確認を行っておくことは重要です。\\ | + | <font color="# |
| - | < | + | </pre></ |
| - | <WRAP mincode>< | + | <WRAP color_result>< |
| - | $ firewall-cmd --list-services | + | FedoraWorkstation |
| + | interfaces: wlp2s0 | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | <WRAP left round tip 95% minfont_12> | ||
| + | はじめに__デフォルトゾーンの確認を行っておくことは重要__です。\\ | ||
| + | < | ||
| + | <html>< | ||
| + | |||
| + | < | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | FedoraWorkstation | ||
| + | </ | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| dhcpv6-client mdns samba-client ssh | dhcpv6-client mdns samba-client ssh | ||
| - | $ firewall-cmd --zone=FedoraWorkstation --list-services | + | </ |
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| dhcpv6-client mdns samba-client ssh | dhcpv6-client mdns samba-client ssh | ||
| - | $ firewall-cmd --zone=FedoraServer --list-services | + | </ |
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| cockpit dhcpv6-client ssh | cockpit dhcpv6-client ssh | ||
| - | </code></ | + | </pre></ |
| + | </ | ||
| - | 例えば、デフォルトゾーンが **FedoraWorkstation** の状態でインタフェース **enp8s0** のアクティブゾーンを **FedoraWorkstation** から **FedoraServer** へ変更した場合、< | + | 例えば、デフォルトゾーンが **FedoraWorkstation** の状態でインタフェース **enp8s0** のアクティブゾーンを **FedoraWorkstation** から **FedoraServer** へ変更した場合、< |
| - | < | + | < |
| - | < | + | < |
| - | $ firewall-cmd --get-default-zone | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result>< | ||
| FedoraWorkstation | FedoraWorkstation | ||
| - | $ firewall-cmd --get-active-zones | + | </ |
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| FedoraWorkstation | FedoraWorkstation | ||
| interfaces: enp8s0 | interfaces: enp8s0 | ||
| libvirt | libvirt | ||
| interfaces: virbr0 | interfaces: virbr0 | ||
| - | $ sudo firewall-cmd --zone=FedoraServer --change-interface=enp8s0 | + | </ |
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| success | success | ||
| - | $ firewall-cmd --get-active-zones | + | </ |
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| FedoraServer | FedoraServer | ||
| interfaces: enp8s0 | interfaces: enp8s0 | ||
| libvirt | libvirt | ||
| interfaces: virbr0 | interfaces: virbr0 | ||
| - | $ firewall-cmd --list-services | + | |
| + | </ | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| You're performing an operation over default zone (' | You're performing an operation over default zone (' | ||
| but your connections/ | but your connections/ | ||
| 行 56: | 行 487: | ||
| dhcpv6-client mdns samba-client ssh | dhcpv6-client mdns samba-client ssh | ||
| - | </code></ | + | </pre></ |
| </ | </ | ||
| - | < | + | <WRAP mincode> |
| メッセージ (翻訳):\\ | メッセージ (翻訳):\\ | ||
| < | < | ||
| 行 66: | 行 497: | ||
| ほとんどの場合、--zone=FedoraServer オプションを使用する必要があります。 | ほとんどの場合、--zone=FedoraServer オプションを使用する必要があります。 | ||
| </ | </ | ||
| - | < | ||
| </ | </ | ||
| - | ===== デフォルトゾーンの変更 ===== | + | ===== デフォルトゾーンとアクティブゾーンの変更 ===== |
| - | workゾーンへ変更 | + | デフォルトゾーンを FedoraServer |
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --set-default-zone=work | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| - | + | </pre></ | |
| - | すべてのアクセスを許可するtrustedゾーンへ変更 | + | <WRAP color_result>< |
| - | <code> | + | success |
| - | $ sudo firewall-cmd --set-default-zone=trusted | + | </ |
| - | </code> | + | <WRAP color_command>< |
| - | ※これらの変更はすぐに反映される。 | + | <font color="# |
| - | + | </ | |
| - | ===== アクティブゾーンの確認 ===== | + | <WRAP color_result>< |
| - | <code> | + | |
| - | $ firewall-cmd --get-active-zones | + | |
| FedoraServer | FedoraServer | ||
| - | | + | </ |
| - | </code> | + | <WRAP color_command>< |
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | FedoraWorkstation | ||
| + | | ||
| + | </ | ||
| + | </ | ||
| + | ※デフォルトゾーンを変更してもアクティブゾーンが変更される訳ではない🤔\\ | ||
| + | これらの変更はすぐに反映される🤔\\ | ||
| + | \\ | ||
| + | アクティブゾーンを FedoraServer へ変更\\ | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | FedoraServer | ||
| + | interfaces: wlp2s0 | ||
| + | </ | ||
| + | </WRAP> | ||
| - | ===== アクティブゾーンの変更 ===== | ||
| - | < | ||
| - | $ sudo firewall-cmd --zone=work --change-interface=ens33 | ||
| - | </ | ||
| ===== 許可されているサービスの確認 ===== | ===== 許可されているサービスの確認 ===== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ firewall-cmd --list-services | + | <WRAP color_command>< |
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| dhcpv6-client mdns samba-client ssh | dhcpv6-client mdns samba-client ssh | ||
| - | </code> | + | </pre></ |
| + | </WRAP> | ||
| ===== 許可されているポートの確認 ===== | ===== 許可されているポートの確認 ===== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ firewall-cmd --list-ports | + | <WRAP color_command>< |
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| 22022/tcp 3389/tcp 5901/tcp | 22022/tcp 3389/tcp 5901/tcp | ||
| - | </code> | + | </pre></ |
| + | </WRAP> | ||
| ===== 登録可能なサービスの確認 ===== | ===== 登録可能なサービスの確認 ===== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ firewall-cmd --get-services | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| - | < | + | </ |
| - | <code> | + | <WRAP color_result>< |
| - | RH-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine cockpit condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client etcd-server finger freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master git gre high-availability http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kerberos kibana klogin kpasswd kprop kshell ldap ldaps libvirt libvirt-tls lightning-network llmnr managesieve matrix mdns minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql nfs nfs3 nmea-0183 nrpe ntp nut openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius redis rpc-bind rsh rsyncd rtsp salt-master samba samba-client samba-dc sane sip sips slp smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-server | + | H-Satellite-6 amanda-client amanda-k5-client amqp amqps apcupsd audit bacula bacula-client bgp bitcoin bitcoin-rpc bitcoin-testnet bitcoin-testnet-rpc ceph ceph-mon cfengine cockpit condor-collector ctdb dhcp dhcpv6 dhcpv6-client distcc dns docker-registry docker-swarm dropbox-lansync elasticsearch etcd-client etcd-server finger freeipa-ldap freeipa-ldaps freeipa-replication freeipa-trust ftp ganglia-client ganglia-master git gre high-availability http https imap imaps ipp ipp-client ipsec irc ircs iscsi-target isns jenkins kadmin kerberos kibana klogin kpasswd kprop kshell ldap ldaps libvirt libvirt-tls lightning-network llmnr managesieve matrix mdns minidlna mongodb mosh mountd mqtt mqtt-tls ms-wbt mssql murmur mysql nfs nfs3 nmea-0183 nrpe ntp nut openvpn ovirt-imageio ovirt-storageconsole ovirt-vmconsole plex pmcd pmproxy pmwebapi pmwebapis pop3 pop3s postgresql privoxy proxy-dhcp ptp pulseaudio puppetmaster quassel radius redis rpc-bind rsh rsyncd rtsp salt-master samba samba-client samba-dc sane sip sips slp smtp smtp-submission smtps snmp snmptrap spideroak-lansync squid ssh steam-streaming svdrp svn syncthing syncthing-gui synergy syslog syslog-tls telnet tftp tftp-client tinc tor-socks transmission-client upnp-client vdsm vnc-server wbem-http wbem-https wsman wsmans xdmcp xmpp-bosh xmpp-client xmpp-local xmpp-server zabbix-agent zabbix-server |
| - | </code> | + | </pre></ |
| </ | </ | ||
| ===== サービスを永続的に許可 ===== | ===== サービスを永続的に許可 ===== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --permanent --add-service=ssh | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </WRAP> | ||
| ===== サービスの許可を永続的に削除 ===== | ===== サービスの許可を永続的に削除 ===== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --permanent --remove-service=ssh | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </ | ||
| + | |||
| + | 複数サービスの許可を一括で永続的に削除🤤\\ | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </WRAP> | ||
| ===== 特定ポートを永続的に許可 ===== | ===== 特定ポートを永続的に許可 ===== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --permanent --add-port=22022/ | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </WRAP> | ||
| ==== 特定ポートの許可を永続的に削除 ==== | ==== 特定ポートの許可を永続的に削除 ==== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --permanent --remove-port=22022/ | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </WRAP> | ||
| ===== アクセス許可 ===== | ===== アクセス許可 ===== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --permanent --add-source=192.168.1.0/ | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </WRAP> | ||
| ===== アクセス拒否 ===== | ===== アクセス拒否 ===== | ||
| drop ゾーンにIPアドレスを登録する。 | drop ゾーンにIPアドレスを登録する。 | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --permanent --add-source=192.168.1.0/ | + | <WRAP color_command>< |
| - | $ sudo firewall-cmd --permanent --add-source=192.168.1.1 --zone=drop | + | <font color="# |
| - | </code> | + | </ |
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </pre></ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </ | ||
| 拒否リストの表示 | 拒否リストの表示 | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --list-sources --zone=drop | + | <WRAP color_command>< |
| + | <font color="# | ||
| 192.168.1.0/ | 192.168.1.0/ | ||
| - | </code> | + | </pre></ |
| + | <WRAP color_result>< | ||
| + | </ | ||
| + | </ | ||
| 拒否リストの削除 | 拒否リストの削除 | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --permanent --remove-source=192.168.1.0/ | + | <WRAP color_command>< |
| - | $ sudo firewall-cmd --permanent --remove-source=192.168.1.1 --zone=drop | + | <font color="# |
| - | </code> | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | </ | ||
| + | </WRAP> | ||
| ===== firewalld の状態を失わずにリロード ===== | ===== firewalld の状態を失わずにリロード ===== | ||
| - | <code> | + | <WRAP color_term> |
| - | $ sudo firewall-cmd --reload | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| + | </ | ||
| + | <WRAP color_result>< | ||
| + | success | ||
| + | </ | ||
| + | </WRAP> | ||
| ===== サービスで許可されるポートを調べる ===== | ===== サービスで許可されるポートを調べる ===== | ||
| - | 各サービスの定義ファイルを調べることにより許可されるポートがわかる。 | + | 各サービスの定義ファイルを調べることにより許可されるポートがわかる。 |
| - | <code> | + | <WRAP color_term> |
| - | $ cat / | + | <WRAP color_command>< |
| - | </code> | + | <font color="# |
| - | <code xml> | + | </pre></ |
| - | <?xml version=" | + | <WRAP color_result>< |
| - | < | + | <font color="# |
| - | < | + | <font color="# |
| - | < | + | <font color="# |
| - | <port protocol=" | + | <font color="# |
| - | </ | + | <font color="# |
| - | </code> | + | <font color="# |
| + | </pre></ | ||
| + | </ | ||
| + | |||
| + | ===== ヘルプ [--help] ===== | ||
| + | <WRAP color_term> | ||
| + | <WRAP color_command>< | ||
| + | <font color="# | ||
| + | </ | ||
| + | <WRAP color_result_long>< | ||
| + | |||
| + | Usage: firewall-cmd [OPTIONS...] | ||
| + | |||
| + | General Options | ||
| + | -h, --help | ||
| + | -V, --version | ||
| + | -q, --quiet | ||
| + | |||
| + | Status Options | ||
| + | --state | ||
| + | --reload | ||
| + | --complete-reload | ||
| + | --runtime-to-permanent | ||
| + | | ||
| + | --check-config | ||
| + | |||
| + | Log Denied Options | ||
| + | --get-log-denied | ||
| + | --set-log-denied=& | ||
| + | Set log denied value | ||
| + | |||
| + | Permanent Options | ||
| + | --permanent | ||
| + | | ||
| + | |||
| + | Zone Options | ||
| + | --get-default-zone | ||
| + | --set-default-zone=& | ||
| + | Set default zone | ||
| + | --get-active-zones | ||
| + | --get-zones | ||
| + | --get-services | ||
| + | --get-icmptypes | ||
| + | --get-zone-of-interface=& | ||
| + | Print name of the zone the interface is bound to [P] | ||
| + | --get-zone-of-source=& | ||
| + | Print name of the zone the source is bound to [P] | ||
| + | --list-all-zones | ||
| + | --new-zone=& | ||
| + | --new-zone-from-file=& | ||
| + | Add a new zone from file with optional name [P only] | ||
| + | --delete-zone=& | ||
| + | --load-zone-defaults=& | ||
| + | Load zone default settings [P only] | ||
| + | --zone=& | ||
| + | | ||
| + | --info-zone=& | ||
| + | --path-zone=& | ||
| + | |||
| + | Policy Options | ||
| + | --get-policies | ||
| + | --get-active-policies | ||
| + | Print currently active policies | ||
| + | --list-all-policies | ||
| + | --new-policy=& | ||
| + | Add a new empty policy | ||
| + | --new-policy-from-file=& | ||
| + | Add a new policy from file with optional name override [P only] | ||
| + | --delete-policy=& | ||
| + | | ||
| + | --load-policy-defaults=& | ||
| + | Load policy default settings | ||
| + | --policy=& | ||
| + | | ||
| + | --info-policy=& | ||
| + | Print information about a policy | ||
| + | --path-policy=& | ||
| + | Print file path of a policy | ||
| + | |||
| + | IPSet Options | ||
| + | --get-ipset-types | ||
| + | --new-ipset=& | ||
| + | Add a new ipset [P only] | ||
| + | --new-ipset-from-file=& | ||
| + | Add a new ipset from file with optional name [P only] | ||
| + | --delete-ipset=& | ||
| + | | ||
| + | --load-ipset-defaults=& | ||
| + | Load ipset default settings [P only] | ||
| + | --info-ipset=& | ||
| + | --path-ipset=& | ||
| + | --get-ipsets | ||
| + | --ipset=& | ||
| + | Set new description to ipset [P only] | ||
| + | --ipset=& | ||
| + | Print description for ipset [P only] | ||
| + | --ipset=& | ||
| + | Set new short description to ipset [P only] | ||
| + | --ipset=& | ||
| + | Print short description for ipset [P only] | ||
| + | --ipset=& | ||
| + | Add a new entry to an ipset [P] | ||
| + | --ipset=& | ||
| + | | ||
| + | --ipset=& | ||
| + | | ||
| + | --ipset=& | ||
| + | List entries of an ipset [P] | ||
| + | --ipset=& | ||
| + | Add a new entries to an ipset [P] | ||
| + | --ipset=& | ||
| + | | ||
| + | |||
| + | IcmpType Options | ||
| + | --new-icmptype=& | ||
| + | Add a new icmptype [P only] | ||
| + | --new-icmptype-from-file=& | ||
| + | Add a new icmptype from file with optional name [P only] | ||
| + | --delete-icmptype=& | ||
| + | | ||
| + | --load-icmptype-defaults=& | ||
| + | Load icmptype default settings [P only] | ||
| + | --info-icmptype=& | ||
| + | Print information about an icmptype | ||
| + | --path-icmptype=& | ||
| + | Print file path of an icmptype [P only] | ||
| + | --icmptype=& | ||
| + | Set new description to icmptype [P only] | ||
| + | --icmptype=& | ||
| + | Print description for icmptype [P only] | ||
| + | --icmptype=& | ||
| + | Set new short description to icmptype [P only] | ||
| + | --icmptype=& | ||
| + | Print short description for icmptype [P only] | ||
| + | --icmptype=& | ||
| + | | ||
| + | --icmptype=& | ||
| + | | ||
| + | --icmptype=& | ||
| + | | ||
| + | --icmptype=& | ||
| + | List destinations in icmptype [P only] | ||
| + | |||
| + | Service Options | ||
| + | --new-service=& | ||
| + | Add a new service [P only] | ||
| + | --new-service-from-file=& | ||
| + | Add a new service from file with optional name [P only] | ||
| + | --delete-service=& | ||
| + | | ||
| + | --load-service-defaults=& | ||
| + | Load icmptype default settings [P only] | ||
| + | --info-service=& | ||
| + | Print information about a service | ||
| + | --path-service=& | ||
| + | Print file path of a service [P only] | ||
| + | --service=& | ||
| + | Set new description to service [P only] | ||
| + | --service=& | ||
| + | Print description for service [P only] | ||
| + | --service=& | ||
| + | Set new short description to service [P only] | ||
| + | --service=& | ||
| + | Print short description for service [P only] | ||
| + | --service=& | ||
| + | Add a new port to service [P only] | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | List ports of service [P only] | ||
| + | --service=& | ||
| + | Add a new protocol to service [P only] | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | List protocols of service [P only] | ||
| + | --service=& | ||
| + | Add a new source port to service [P only] | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | List source ports of service [P only] | ||
| + | --service=& | ||
| + | Add a new helper to service [P only] | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | List helpers of service [P only] | ||
| + | --service=& | ||
| + | Set destination for ipv to address in service [P only] | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | List destinations in service [P only] | ||
| + | --service=& | ||
| + | Add a new include to service [P only] | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | | ||
| + | --service=& | ||
| + | List includes of service [P only] | ||
| + | |||
| + | Options to Adapt and Query Zones and Policies | ||
| + | --list-all | ||
| + | --timeout=& | ||
| + | a number followed by one of letters ' | ||
| + | | ||
| + | --set-description=& | ||
| + | Set new description [P only] [Z] [O] | ||
| + | --get-description | ||
| + | --get-target | ||
| + | --set-target=& | ||
| + | Set the target [P only] [Z] [O] | ||
| + | --set-short=& | ||
| + | Set new short description [Z] [O] | ||
| + | --get-short | ||
| + | --list-services | ||
| + | --add-service=& | ||
| + | Add a service [P] [Z] [O] [T] | ||
| + | --remove-service=& | ||
| + | | ||
| + | --query-service=& | ||
| + | | ||
| + | --list-ports | ||
| + | --add-port=& | ||
| + | Add the port [P] [Z] [O] [T] | ||
| + | --remove-port=& | ||
| + | | ||
| + | --query-port=& | ||
| + | | ||
| + | --list-protocols | ||
| + | --add-protocol=& | ||
| + | Add the protocol [P] [Z] [O] [T] | ||
| + | --remove-protocol=& | ||
| + | | ||
| + | --query-protocol=& | ||
| + | | ||
| + | --list-source-ports | ||
| + | --add-source-port=& | ||
| + | Add the source port [P] [Z] [O] [T] | ||
| + | --remove-source-port=& | ||
| + | | ||
| + | --query-source-port=& | ||
| + | | ||
| + | --list-icmp-blocks | ||
| + | --add-icmp-block=& | ||
| + | Add an ICMP block [P] [Z] [O] [T] | ||
| + | --remove-icmp-block=& | ||
| + | | ||
| + | --query-icmp-block=& | ||
| + | | ||
| + | --list-forward-ports List IPv4 forward ports added [P] [Z] [O] | ||
| + | --add-forward-port=port=& | ||
| + | Add the IPv4 forward port [P] [Z] [O] [T] | ||
| + | --remove-forward-port=port=& | ||
| + | | ||
| + | --query-forward-port=port=& | ||
| + | | ||
| + | --add-masquerade | ||
| + | --remove-masquerade | ||
| + | --query-masquerade | ||
| + | --list-rich-rules | ||
| + | --add-rich-rule=& | ||
| + | Add rich language rule ' | ||
| + | --remove-rich-rule=& | ||
| + | | ||
| + | --query-rich-rule=& | ||
| + | | ||
| + | added [P] [Z] [O] | ||
| + | |||
| + | Options to Adapt and Query Zones | ||
| + | --add-icmp-block-inversion | ||
| + | | ||
| + | --remove-icmp-block-inversion | ||
| + | | ||
| + | --query-icmp-block-inversion | ||
| + | | ||
| + | for a zone [P] [Z] | ||
| + | --add-forward | ||
| + | | ||
| + | --remove-forward | ||
| + | | ||
| + | --query-forward | ||
| + | and sources has been enabled for a zone [P] [Z] | ||
| + | |||
| + | Options to Adapt and Query Policies | ||
| + | --get-priority | ||
| + | --set-priority=& | ||
| + | Set the priority [P only] [O] | ||
| + | --list-ingress-zones | ||
| + | List ingress zones that are bound to a policy [P] [O] | ||
| + | --add-ingress-zone=& | ||
| + | Add the ingress zone to a policy [P] [O] | ||
| + | --remove-ingress-zone=& | ||
| + | | ||
| + | --query-ingress-zone=& | ||
| + | Query whether the ingress zone has been adedd to a | ||
| + | | ||
| + | --list-egress-zones | ||
| + | List egress zones that are bound to a policy [P] [O] | ||
| + | --add-egress-zone=& | ||
| + | Add the egress zone to a policy [P] [O] | ||
| + | --remove-egress-zone=& | ||
| + | | ||
| + | --query-egress-zone=& | ||
| + | Query whether the egress zone has been adedd to a | ||
| + | | ||
| + | |||
| + | Options to Handle Bindings of Interfaces | ||
| + | --list-interfaces | ||
| + | --add-interface=& | ||
| + | Bind the & | ||
| + | --change-interface=& | ||
| + | | ||
| + | --query-interface=& | ||
| + | Query whether & | ||
| + | --remove-interface=& | ||
| + | | ||
| + | |||
| + | Options to Handle Bindings of Sources | ||
| + | --list-sources | ||
| + | --add-source=& | ||
| + | Bind the source to a zone [P] [Z] | ||
| + | --change-source=& | ||
| + | | ||
| + | --query-source=& | ||
| + | Query whether the source is bound to a zone [P] [Z] | ||
| + | --remove-source=& | ||
| + | | ||
| + | |||
| + | Helper Options | ||
| + | --new-helper=& | ||
| + | Add a new helper [P only] | ||
| + | --new-helper-from-file=& | ||
| + | Add a new helper from file with optional name [P only] | ||
| + | --delete-helper=& | ||
| + | | ||
| + | --load-helper-defaults=& | ||
| + | Load helper default settings [P only] | ||
| + | --info-helper=& | ||
| + | --path-helper=& | ||
| + | --get-helpers | ||
| + | --helper=& | ||
| + | Set new description to helper [P only] | ||
| + | --helper=& | ||
| + | Print description for helper [P only] | ||
| + | --helper=& | ||
| + | Set new short description to helper [P only] | ||
| + | --helper=& | ||
| + | Print short description for helper [P only] | ||
| + | --helper=& | ||
| + | Add a new port to helper [P only] | ||
| + | --helper=& | ||
| + | | ||
| + | --helper=& | ||
| + | | ||
| + | --helper=& | ||
| + | List ports of helper [P only] | ||
| + | --helper=& | ||
| + | Set module to helper [P only] | ||
| + | --helper=& | ||
| + | Get module from helper [P only] | ||
| + | --helper=& | ||
| + | Set family for helper [P only] | ||
| + | --helper=& | ||
| + | Get module from helper [P only] | ||
| + | |||
| + | Direct Options | ||
| + | --direct | ||
| + | --get-all-chains | ||
| + | Get all chains [P] | ||
| + | --get-chains {ipv4|ipv6|eb} & | ||
| + | Get all chains added to the table [P] | ||
| + | --add-chain {ipv4|ipv6|eb} & | ||
| + | Add a new chain to the table [P] | ||
| + | --remove-chain {ipv4|ipv6|eb} & | ||
| + | | ||
| + | --query-chain {ipv4|ipv6|eb} & | ||
| + | | ||
| + | --get-all-rules | ||
| + | Get all rules [P] | ||
| + | --get-rules {ipv4|ipv6|eb} & | ||
| + | Get all rules added to chain in table [P] | ||
| + | --add-rule {ipv4|ipv6|eb} & | ||
| + | Add rule to chain in table [P] | ||
| + | --remove-rule {ipv4|ipv6|eb} & | ||
| + | | ||
| + | --remove-rules {ipv4|ipv6|eb} & | ||
| + | | ||
| + | --query-rule {ipv4|ipv6|eb} & | ||
| + | | ||
| + | chain in table [P] | ||
| + | --passthrough {ipv4|ipv6|eb} & | ||
| + | Pass a command through (untracked by firewalld) | ||
| + | --get-all-passthroughs | ||
| + | Get all tracked passthrough rules [P] | ||
| + | --get-passthroughs {ipv4|ipv6|eb} & | ||
| + | Get tracked passthrough rules [P] | ||
| + | --add-passthrough {ipv4|ipv6|eb} & | ||
| + | Add a new tracked passthrough rule [P] | ||
| + | --remove-passthrough {ipv4|ipv6|eb} & | ||
| + | | ||
| + | --query-passthrough {ipv4|ipv6|eb} & | ||
| + | | ||
| + | added [P] | ||
| + | |||
| + | Lockdown Options | ||
| + | --lockdown-on | ||
| + | --lockdown-off | ||
| + | --query-lockdown | ||
| + | |||
| + | Lockdown Whitelist Options | ||
| + | --list-lockdown-whitelist-commands | ||
| + | List all command lines that are on the whitelist [P] | ||
| + | --add-lockdown-whitelist-command=& | ||
| + | Add the command to the whitelist [P] | ||
| + | --remove-lockdown-whitelist-command=& | ||
| + | | ||
| + | --query-lockdown-whitelist-command=& | ||
| + | Query whether the command is on the whitelist [P] | ||
| + | --list-lockdown-whitelist-contexts | ||
| + | List all contexts that are on the whitelist [P] | ||
| + | --add-lockdown-whitelist-context=& | ||
| + | Add the context context to the whitelist [P] | ||
| + | --remove-lockdown-whitelist-context=& | ||
| + | | ||
| + | --query-lockdown-whitelist-context=& | ||
| + | Query whether the context is on the whitelist [P] | ||
| + | --list-lockdown-whitelist-uids | ||
| + | List all user ids that are on the whitelist [P] | ||
| + | --add-lockdown-whitelist-uid=& | ||
| + | Add the user id uid to the whitelist [P] | ||
| + | --remove-lockdown-whitelist-uid=& | ||
| + | | ||
| + | --query-lockdown-whitelist-uid=& | ||
| + | Query whether the user id uid is on the whitelist [P] | ||
| + | --list-lockdown-whitelist-users | ||
| + | List all user names that are on the whitelist [P] | ||
| + | --add-lockdown-whitelist-user=& | ||
| + | Add the user name user to the whitelist [P] | ||
| + | --remove-lockdown-whitelist-user=& | ||
| + | | ||
| + | --query-lockdown-whitelist-user=& | ||
| + | Query whether the user name user is on the whitelist [P] | ||
| + | |||
| + | Panic Options | ||
| + | --panic-on | ||
| + | --panic-off | ||
| + | --query-panic | ||
| + | |||
| + | </ | ||
| + | </ | ||
| + | |||
| + | ===== 参考文献 ===== | ||
| + | |||
| + | ==== 付録 ==== | ||
| + | [[tw> | ||