我对缺乏完整的nftable文档感到有点沮丧,而且目前我甚至无法找到一个简单的示例来工作。我正在尝试创建一个输出规则。这是我唯一的桌子:
root@localhost ~ # nft list ruleset
table inet filter {
chain output {
type filter hook output priority 0; policy accept;
}
}我想把寄出的邮包数目计算为8.8.8.8。所以我使用了nftables (https://wiki.nftables.org/wiki-nftables/index.php/Simple_规则_管理)中的示例命令:
root@localhost ~ # nft add rule filter output ip daddr 8.8.8.8 counter
Error: Could not process rule: No such file or directory
add rule filter output ip daddr 8.8.8.8 counter
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^但出于某种原因,我得到的错误信息非常少。我做错了什么,添加输出规则的正确方法是什么?
root@localhost ~ # uname -a
Linux localhost 4.15.3-2-ARCH #1 SMP PREEMPT Thu Feb 15 00:13:49 UTC 2018 x86_64 GNU/Linux
root@localhost ~ # nft --version
nftables v0.8.2 (Joe Btfsplk)
root@localhost ~ # lsmod|grep '^nf'
nfnetlink_queue 28672 0
nfnetlink_log 20480 0
nf_nat_masquerade_ipv6 16384 1 ip6t_MASQUERADE
nf_nat_ipv6 16384 1 ip6table_nat
nf_nat_masquerade_ipv4 16384 1 ipt_MASQUERADE
nf_nat_ipv4 16384 1 iptable_nat
nf_nat 36864 4 nf_nat_masquerade_ipv6,nf_nat_ipv6,nf_nat_masquerade_ipv4,nf_nat_ipv4
nft_reject_inet 16384 0
nf_reject_ipv4 16384 1 nft_reject_inet
nf_reject_ipv6 16384 1 nft_reject_inet
nft_reject 16384 1 nft_reject_inet
nft_meta 16384 0
nf_conntrack_ipv6 16384 2
nf_defrag_ipv6 36864 1 nf_conntrack_ipv6
nf_conntrack_ipv4 16384 2
nf_defrag_ipv4 16384 1 nf_conntrack_ipv4
nft_ct 20480 0
nf_conntrack 155648 10 nft_ct,nf_conntrack_ipv6,nf_conntrack_ipv4,ipt_MASQUERADE,nf_nat_masquerade_ipv6,nf_nat_ipv6,nf_nat_masquerade_ipv4,ip6t_MASQUERADE,nf_nat_ipv4,nf_nat
nft_set_bitmap 16384 0
nft_set_hash 28672 0
nft_set_rbtree 16384 0
nf_tables_inet 16384 2
nf_tables_ipv6 16384 1 nf_tables_inet
nf_tables_ipv4 16384 1 nf_tables_inet
nf_tables 106496 10 nft_ct,nft_set_bitmap,nft_reject,nft_set_hash,nf_tables_ipv6,nf_tables_ipv4,nft_reject_inet,nft_meta,nft_set_rbtree,nf_tables_inet
nfnetlink 16384 3 nfnetlink_log,nfnetlink_queue,nf_tables发布于 2018-02-28 22:56:06
正确的命令是
root@localhost ~ # nft add rule inet filter output ip daddr 8.8.8.8 counter 注意表名(filter)前面的inet前缀。那是桌子上的家族型。它是可选的,但如果省略它,则nft假设为ip (= IPv4),但我使用的是inet伪家族( IPv4和IPv6)。
多亏了Freenode上的#netfilter频道的人,我学到了这一点。
不用说,nft错误消息是毫无帮助的。:-)
https://unix.stackexchange.com/questions/427210
复制相似问题