0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

firewall-cmd のよく使うオプションまとめ

Last updated at Posted at 2019-09-08

CentOS 7 で確認。firewall-cmd のバージョンは 0.5.3。

ポートを開けるときは、サービスにポートを割り当ててから、サービスをゾーンに追加すると、管理しやすい。--add-port でポートを開けるのはやめたほうがいいと思う。

定義済みサービスのリストを表示

firewall-cmd --permanent --get-services

新規サービスを作成

firewall-cmd --permanent --new-service=<サービス名>

サービスに登録されているポートのリストを表示

firewall-cmd --permanent --service=<サービス名> --get-ports

サービスにポートを追加

firewall-cmd --permanent --service=<サービス名> --add-port=<ポート番号>/<プロトコル>

ポート番号は 50001-50009 のように範囲指定もできる。

サービスからポートを削除

firewall-cmd --permanent --service=<サービス名> --remove-port=<ポート番号>/<プロトコル>

ポート番号は 50001-50009 のように範囲指定もできる。

デフォルトゾーンに登録されているサービスのリストを表示

firewall-cmd --permanent --list-services

デフォルトゾーンにサービスを追加

firewall-cmd --permanent --add-service=<サービス名>

デフォルトゾーンからサービスを削除

firewall-cmd --permanent --remove-service=<サービス名>

変更した設定を反映

firewall-cmd --reload
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?