2
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 3 years have passed since last update.

nf_tablesのnftコマンドメモ (CentOS8)

Last updated at Posted at 2020-11-23
設定の削除
# nft flush ruleset
tableの作成
# nft create table mytable1
# nft list ruleset ip ##確認
chainの作成
# nft add chain ip mytable1 mychain1 { type filter hook input priority 0 \; }
# nft -a list chain ip mytable1 mychain1 ##確認
sshの許可
# nft add rule mytable1 mychain1 tcp dport 22 accept
ルールを追加するたびに確認
# nft -a list chain ip mytable1 mychain1
ssh以外の拒否
# nft add rule mytable1 mychain1 drop
戻りの通信は通す
# nft add rule mytable1 mychain1 handle 2 ct state related,established accept
icmp許可
# nft add rule mytable1 mychain1 handle 6 icmp type { echo-request, echo-reply } accept
8080許可
# nft add rule mytable1 mychain1 handle 2 tcp dport 8080 ip saddr 192.168.11.0/24 accept
10050許可
# nft add rule mytable1 mychain1 handle 10 tcp dport 10050 ip saddr 192.168.11.0/24 accept
設定書き出し
# nft list ruleset > ruleset.conf
設定読み込み
# nft -c ruleset.conf ## チェック
# nft -f ruleset.conf
削除
## table削除
# nft delete table mytable1

## chain削除
# nft delete chain mytable1 mychain1

## chain内のルールはhandleを指定して削除する
# nft delete rule myrule1 mychain1 handle 11
有効化
# systemctl enable nftables.service
# systemctl start nftables.service
# nft list ruleset > /etc/sysconfig/nftables.conf ##CentOS,RHELの場合
# サーバ再起動して設定が読み込まれているかチェック。

参考にしたサイト

https://knowledge.sakura.ad.jp/22636/
https://mimumimu.net/blog/2019/12/07/iptables-%E3%81%8B%E3%82%89-nftables-%E3%81%AB%E3%82%B5%E3%82%AF%E3%83%83%E3%81%A8%E5%88%87%E3%82%8A%E6%9B%BF%E3%81%88%E3%82%8B/

2
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
2
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?