.png)
Fedora 32 にアップグレードしましたが、nftables を使用するため、まったく馴染みがなく、見つけられるすべてのドキュメントを精査した後でも、nftables を使用して 1:1 NAT を複製する方法がわかりません。つまり、現在、メール サーバーにアクセスできません。
私はこれらのルールをfirewalld/iptablesで使用していました。
<passthrough ipv="ipv4">-t nat -A PREROUTING -i eno1 -d public.ip -j DNAT --to-destination 10.99.99.21</passthrough>
<passthrough ipv="ipv4">-t nat -A POSTROUTING -s 10.99.99.21 -o eno1 -j SNAT --to public.ip</passthrough>
<passthrough ipv="ipv6">-t nat -A PREROUTING -i eno1 -d public.ipv6 -j DNAT --to-destination fdb9:b611:5d5d:ffff::21</passthrough>
<passthrough ipv="ipv6">-t nat -A POSTROUTING -s fdb9:b611:5d5d:ffff::21 -o eno1 -j SNAT --to-source public.ipv6</passthrough>
これを試してみましたが、うまくいかないようです:
nft list table nat
table ip nat {
chain postrouting {
type nat hook postrouting priority srcnat; policy accept;
ip saddr 10.99.99.21 oif "eno1" snat to public.ip
}
chain prerouting {
type nat hook prerouting priority dstnat; policy accept;
iif "eno1" ip daddr public.ip dnat to 10.99.99.21
}
}
詳細情報: さらに調査したところ、何らかの理由で SNAT ルールが一致していないことがわかりました。
答え1
github の firewalld の開発者の 1 人と話し合った結果、自分の疑問がわかったので、その答えを述べたいと思います。
どうやら問題は、nftables と iptables の両方が同時に使用されていることです。
引用:
This makes sense. It's due to the fact that iptables and nftables rules are executed independently inside the kernel/netfilter. So your scenarios are:
iptables backend
your direct rules accept the packets in the FORWARD chain
further iptables rules in the FORWARD chain are not evaluated (due to accept)
firewalld rules are part of iptables, so they're not considered (due to accept)
nftables backend
your direct rules accept the packets in the FORWARD chain
further iptables rules in the FORWARD chain are not evaluated (due to accept)
packet is now subject to firewalld's nftables ruleset, this happens even if the packet is accepted it iptables.
zone is using "default" target, so packet is dropped in the FORWARD chain
due to drop POSTROUTING (SNAT) is never reached
There is no fix possible as it's a result of how the kernel works. You can read more about this in the CAVEATS section of man page firewalld.direct.
ソース:参考:
したがって、iptables-nft の代替手段で作成された上記の nftables ルールは、iptables カーネル コードを引き続き使用するため機能しません。それらは nft 上に表示されるだけです。
nftables と iptables の相互作用に関する詳細な説明は、こちらをご覧ください: https://developers.redhat.com/blog/2020/08/18/iptables-the-two-variants-and-their-relationship-with-nftables/