
私はFreeBSD 12.3で受信インターフェイスと送信インターフェイスに基づいてフィルタリングする単純な転送ルール(ポート転送ではありません!)を設定したいと思います。 IPネットワーキングはすべてのタイプのIPのルーターと同じであるため、ルールの一部にしてはいけません。ルーティングされたネットワークは、ルーティングデーモン(OSPFを含むBIRD)によって動的に設定されます。
PFを使用するFreeBSDでは、ifspec
フィルタルールごとに1つしか設定できません([ "on" ifspec ]
男5 pf.conf:
pf-rule = action [ ( "in" | "out" ) ]
[ "log" [ "(" logopts ")"] ] [ "quick" ]
[ "on" ifspec ] [ route ] [ af ] [ protospec ]
hosts [ filteropt-list ]
入力と出力インターフェイスの組み合わせが一致したいです。どうすればいいですか?
Linuxでnft
/ nftablesを使用すると、次のことができます。
define iface_site2site = { "tun0", "tun1", "tun9" }
[...]
chain forward {
type filter hook forward priority 0;
policy drop;
iifname $iface_site2site oifname $iface_site2site accept \
comment "Freely forward packets between site-to-site links, firewalled at final destination."
}
[...]
Linuxでは、iptables
次のようにします。
iptables -A [...] --in-interface tun+ --out-interface tun+ -j ACCEPT
FreeBSDで上記の操作をどのように実行しますか?
はっきり言えば私はそうです。いいえポート転送またはNATルールを見つけます。
答え1
FreeBSDでは、単一のルールでこれを行うことはできません。したがって、match
ルールを使用してこれらのインターフェイスでインバウンドトラフィックを表示し、pass
forin
とforの2つのルールを使用してout
から、そのようにマークされている場合にのみトラフィックが出ることを許可できます。
FreeBSD 12.3のman pf.conf(5)によると:
tag <string> Packets matching this rule will be tagged with the specified string. The tag acts as an internal marker that can be used to identify these packets later on. This can be used, for example, to provide trust between interfaces and to determine if packets have been processed by translation rules. Tags are "sticky", meaning that the packet will be tagged even if the rule is not the last matching rule. [...]
質問のユースケース(「インターフェース間の信頼の提供」)がよく言及されています。