LoginSignup
5
6

More than 3 years have passed since last update.

来たるnftablesの概要などなど

Last updated at Posted at 2019-09-15

nft(8)

firewall_icon.png

nft - Administration tool of the nftables framework for packet filtering and classification  

背景

自宅でnftablesを使ってみようと思うきっかけがあったので記事にしてみました。

nftables概要

Linux Kernel 3.13から、パケットフィルタリングなどを管理するツールで「iptables」に代わって、nftablesを採用するLinuxディストリビューションが増えてきています(*)。
nftablesを使ったパケットフィルタリングの設定、コマンド操作の違いについて簡単に解説します。

[※] ちなみにRHEL8より、新たなパケットフィルタリングツールとして nftables が導入されました。
[※] Debian 10 コードネーム「Buster」)からnftablesも導入されています。

メリット

  • フィルターの処理が、線形処理からテーブル探索に変更
  • ネットワーク層以外のプロトコルも管理可能
  • 文法の取得しやすさ、学習コストの低減

こんな感じでしょうか。3点目に関しては個人的にはとても大きいなと感じました。

テーブル

nftables には初めから組み込まれているテーブルはありません。テーブルの数や名前はユーザーが自由に決めることができます。

nftables ファミリー iptables ユーティリティ
ip iptables
ip6 ip6tables
inet iptables と ip6tables
arp arptables
bridge ebtables

コマンド

テーブル関連

# Usage
$ nft [ -nNscae ] [ -I directory ] [ -f filename | -i | cmd ...] nft -h nft -v  

# テーブル作成
$ nft add table family table

# 全てのテールブを表示
$ nft list tables

# テーブル内のチェインとルールを表示
$ nft list table family table
$ nft list table inet filter

# テーブル削除
$ nft delete table family table

# テーブルクリア
$ nft flush table family table

チェイン関連

# Usage
$ nft [ -nNscae ] [ -I directory ] [ -f filename | -i | cmd ...] nft -h nft -v

# baseチェイン追加
$ nft add chain family table chain { type type hook hook priority priority \; }

# ルールの表示
$ nft list chain family table chain

# チェインの編集
$ nft chain <table> <family> <chain> { [ type <type> hook <hook> device <device> priority <priority> \; policy <policy> \; ] }

# チェインの削除
$ nft delete chain family table chain

# チェインのルール削除
$ nft flush chain family table chain

移行

iptablesからのnftablesへの以降作業についてはすでに色々な方が便利に安全にやる方法をあげているようです。
実際の作業が発生した場合はこういった情報を活かせればいいなって感じでしょうか。
(ちなみに私は全て手で変えてました。。。)

参考記事

5
6
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
5
6