23.05 在构建固件时,还能用回 iptables 么, nftables 感觉有些不太好用

82 天前
 qazwsxkevin

在 menuconfig 里,似乎已经没有 iptables 能选了,openwrt 的 nftable 不知道是版本精简还是我自己语法问题..

root@openwrt:~# nft add table trouter
root@openwrt:~# 
root@openwrt:~# 
root@openwrt:~# 
root@openwrt:~# nft add chain trouter icmp_filter { type filter hook input priority 0 \; }
root@openwrt:~# nft add rule trouter icmp_filter iifname "eth0" icmp type echo-request drop
root@openwrt:~# 
root@openwrt:~# 
root@openwrt:~# nft add rule trouter icmp_filter iifname "br-lan" icmp type echo-request drop
root@openwrt:~# 
root@openwrt:~# 
root@openwrt:~# nft add rule trouter input iifname { "eth0", "br-lan" } icmp type echo-request counter jump icmp_filter
Error: Could not process rule: No such file or directory
add rule trouter input iifname { eth0, br-lan } icmp type echo-request counter jump icmp_filter
                 ^^^^^
root@openwrt:~# 
root@openwrt:~# nft add rule trouter input iifname eth0,br-lan icmp type echo-request counter jump icmp_filter
Error: Basetype of type network interface name is not bitmask
add rule trouter input iifname eth0,br-lan icmp type echo-request counter jump icmp_filter
                               ^^^^
root@openwrt:~# 
root@openwrt:~# nft add rule trouter input iifname { eth0, br-lan } icmp type echo-request counter jump icmp_filter
Error: Could not process rule: No such file or directory
add rule trouter input iifname { eth0, br-lan } icmp type echo-request counter jump icmp_filter
                 ^^^^^
root@openwrt:~# 
root@openwrt:~# 

要是 iptables ,这事情早结束了。。。。

1419 次点击
所在节点    OpenWrt
9 条回复
qazwsxkevin
82 天前
这些语句都是看文档,问 chatgpt 拼装出来,debian 这样 linux 里能完整输入命令
wuruxu
82 天前
```
-----------------------------------------------------
OpenWrt SNAPSHOT, r26907-62891c749d
-----------------------------------------------------
root@jdc128G:~# cat /etc/nftables.d/20-mangle-wgset.nft
chain mangle_prerouting_wgset {
type filter hook prerouting priority mangle; policy accept;
ip daddr @wgset meta mark set 0x00003c25 counter accept
ip6 daddr @wgset6 meta mark set 0x00003c26 counter accept
}

chain mangle_output_wgset {
type route hook output priority mangle; policy accept;
ip daddr @wgset meta mark set 0x00003c25 counter accept
ip6 daddr @wgset6 meta mark set 0x00003c26 counter accept
}
```
可以把 nft 的 rule 添加到 /etc/nftables.d/ 这个目录下
Earsum
81 天前
这个是 22.03 版的官方文档提供的方式,不知道 23 版是否仍然适用,而且这些工具集不是卸载 fw3 更换 fw4 ,而是提供兼容层?
“iptables 工具集不再默认在固件中安装。若有需要,你可以通过 opkg 或者 ImageBuilder 来安装。iptables-nft, arptables-nft, ebtables-nft 和 xtables-nft 软件包可以在使用 nftables 的情况下,提供与之前的工具相同的命令接口。 ”
by https://openwrt.org/zh/releases/22.03/notes-22.03.0
junjiego2
80 天前
最近从 lean 的 lede 换到 immortalwrt 23.05 ,从 iptables 换到 nftables 真的很不习惯,特别是没有了那个自定义规则
szdosar
80 天前
我不确定的是不是用的官方的 openwrt 源码。

如果是的话,你要在配置选单里,降级 firewall 版本:
1.导航到 Base system --->
2.取消 firewall4
3.勾选 firewall

如果你用的是 lede 源码,应该没有这个困扰。
如果你用其他源码,没办法完成以上操作,你可能需要执行这条命令后才能进行以上修改:
sed -i 's/+uci-firewall/+firewall/g' feeds/luci/applications/luci-app-firewall/Makefile
##文件 feeds/luci/applications/luci-app-firewall/Makefile 中所有的 +uci-firewall 都会被替换为 +firewall 。
qazwsxkevin
79 天前
这个问题已解决,正如 3 楼给的 22.03 news 里面提到,在 23.05menuconfig 选上 iptables-nft, arptables-nft, ebtables-nft 和 xtables-nft ,构建好的固件,iptables 1.8 ,又回来了,与 nftables 也是共存的,事情解决,我不想用 nftables ,虽然这个是以后的趋势态度吧,以后再说了...

@wuruxu #2 ,试过写了一些 nftables 的语句,没能正确起效,已经逃了
@Earsum #3 ,感谢~
@junjiego2 #4 ,已解决,23.05 也能用 iptables 了.
@szdosar #5 ,thanks~
sq123
63 天前
@Earsum 但是大佬,纯老版本能用网易 UU 加速器,安装 4 个 nft 插件还是不能用。
Earsum
63 天前
@sq123 这个我就不太清楚了,因为我个人没开源洁癖,用的是 lean's lede 源码
sq123
63 天前
@Earsum 好吧,谢谢。我现在还在用 R7800 (等 wifi7 大推广普及后再换),lede 的 ipq806X 的 ath10k-ct 有问题,每次编译失败,只能用官方的了,官方的 23.05.4 安 4 个插件打开 UU 加速游戏还是像没安装一样,手机 APP 一点就加速失败,看来只能放弃用手机热点将就了!

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/1055750

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX