找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 5665|回复: 16

[openwrt(x86)] PVE下用lxc运行Openwrt实时信息 连接列表为空解决办法。

[复制链接]
发表于 2021-12-13 14:25 | 显示全部楼层 |阅读模式
今年8月份的时候openwrt 更新了 lxc 容器运行openwrt指南,https://openwrt.org/docs/guide-user/virtualization/lxc。而且openwrt 的lxc 镜像发布到了 linuxcontainers官方站点。
表示通过lxc容器运行openwrt已经相当成熟了。
最近新安装了个lxc 的openwrt容器作为旁路由来跑一些服务。发现Openwrt实时信息 连接列表是空的,不完美。
分析了一下,发现是ubuntu、Debian 不再有/proc/net/nf_conntrack,有人提过这个issue,但是ghost回复 “Whilst the code is considered obsolete it has not been removed yet and still works with the kconfig enabled, thus perhaps nothing to be concerned about for now.”。看样子短期内openwrt 还不会采取新的conntrack工具来获取连接列表了。只能自己动手解决了。

第一步:安装 conntrack 操作工具
opkg update && opkg install conntrack
第二步:编辑  /usr/lib/lua/luci/sys.lua 文件,找到function net.conntrack(callback)函数,修改成如下
  1. function net.conntrack(callback)
  2.         --[[
  3.         local ok, nfct = pcall(io.lines, "/proc/net/nf_conntrack")
  4.         if not ok or not nfct then
  5.                 return nil
  6.         end
  7.         --]]

  8.         local nfctipv4 = luci.util.exec("/usr/sbin/conntrack -L -o extended")
  9.         if not nfctipv4 then
  10.                 return nil
  11.         end
  12.         local nfctipv6 = luci.util.exec("/usr/sbin/conntrack -L -f ipv6 -o extended")

  13.         local nfct = (nfctipv4..nfctipv6):gmatch("([^\n]*)\n?")
复制代码

再刷新看看,连接列表应该就有了。 至于上面的连接数量及图表,因为openwrt是在C语言代码里面读取/proc/net/ip_conntrack并操作的,所以不是那么容易就修改了。


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2021-12-13 14:28 | 显示全部楼层
本帖最后由 dominic 于 2021-12-13 14:41 编辑

官方lxc 镜像下载路径 https://us.lxd.images.canonical. ... 1.02/amd64/default/   下日期目录下 文件 rootfs.tar.xz。比如:
https://us.lxd.images.canonical.com/images/openwrt/21.02/amd64/default/20211212_11:57/rootfs.tar.xz


这镜像文件在pve里面还是不能直接使用web界面进行安装,因为pve识别到openwrt的镜像文件rootfs中存在/etc/os-release 文件,而直接就终止了安装了,还是的需要使用pct命令行来安装openwrt lxc。
几点建议:
1、pve 7对openwrt这个lxc 容器支持非常好了。基本不需要在config文件里面添加lxc开头的配置就可以很好的运行了。
2、完美支持unprivileged 。也就是可以设置 unprivileged:1 了,也就是启用无特权容器。
3、如果还要在openwrt里面运行docker,需要设置config文件 features: keyctl=1,nesting=1
4、建议取消apparmor。也就是config文件中添加。lxc.apparmor.profile = unconfined。
5、pve中启用bbr之后openwrt也支持bbr了,所以建议在pve中启用bbr。
6、特殊需要挂载proc sys 等系统目录,可通过就是config文件中添加 配置来调整。lxc.mount.auto: proc:mixed sys:ro cgroup:mixed。
7、其他一些网络优化sysctl配置可能不需要另外设置了,pve中设置已经很优化了,会自动带到openwrt中。

点评

大佬打扰了,今天我换了PVE 7.1。建立LXC OP后在lxcid.conf添加了 lxc.mount.entry = /dev/ppp dev/ppp none bind,optional,create=file,rw lxc.cgroup2.devices.allow = c 108:0 rwm lxc.cap.keep = net_admin启动l  详情 回复 发表于 2022-1-16 00:35
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2021-12-13 15:36 | 显示全部楼层
本帖最后由 yjd159 于 2021-12-13 15:58 编辑

真官方镜像地址:https://downloads.openwrt.org/releases/21.02.1/targets/x86/64/openwrt-21.02.1-x86-64-rootfs.tar.gz


点评

没毛病。 lxd.images.canonical.com 是https://linuxcontainers.org/ 也就是lxc 的官方发布站。 普通linux用lxc-create就可以创建的。  详情 回复 发表于 2021-12-13 16:57
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2021-12-13 16:57 | 显示全部楼层
yjd159 发表于 2021-12-13 15:36
真官方镜像地址:https://downloads.openwrt.org/releases/21.02.1/targets/x86/64/openwrt-21.02.1-x86-64 ...

没毛病。
lxd.images.canonical.com 是https://linuxcontainers.org/ 也就是lxc 的官方发布站。
普通linux用lxc-create就可以创建的。

点评

楼主你好,我把lxc.mount.entry = /dev/ppp dev/ppp none bind,optional,create=file,rw lxc.cgroup2.devices.allow = c 108:0 rwm lxc.cap.keep = net_admin添加到lxc的id.conf里面 启动op还是不能拨号。 日志  详情 回复 发表于 2022-1-10 14:32
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-1-6 19:30 | 显示全部楼层
十分感谢
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-1-8 12:22 来自手机 | 显示全部楼层
楼主请问pve7用lxc openwrt pppoe拨号要怎么做?我装好lxc openwrt设置pppoe拨号没反应。谢谢

点评

需要添加 lxc.mount.entry = /dev/ppp dev/ppp none bind,optional,create=file,rw lxc.cgroup2.devices.allow = c 108:0 rwm lxc.cap.keep = net_admin 也就是把设备/dev/ppp 挂载到lxc里面去。  详情 回复 发表于 2022-1-10 12:30
需要添加 lxc.mount.entry = /dev/ppp dev/ppp none bind,optional,create=file,rw lxc.cgroup2.devices.allow = c 108:0 rwm 也就是把设备/dev/ppp 挂载到lxc里面去。  详情 回复 发表于 2022-1-10 12:23
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-1-10 14:32 | 显示全部楼层
dominic 发表于 2021-12-13 16:57
没毛病。
lxd.images.canonical.com 是https://linuxcontainers.org/ 也就是lxc 的官方发布站。
普通li ...

楼主你好,我把lxc.mount.entry = /dev/ppp dev/ppp none bind,optional,create=file,rw lxc.cgroup2.devices.allow = c 108:0 rwm lxc.cap.keep = net_admin添加到lxc的id.conf里面
启动op还是不能拨号。

日志:





本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×

点评

请问有支持lxc的5.13内核下载地址吗?到处找不到内核下载,下了5.15内核,不稳定,经常重启。  详情 回复 发表于 2022-9-19 16:44
内核5.4 你这是pve 6.2吧。cgroup2 是pve7里面的。pve7 kernel是5.11起步。当前稳定内核是5.13。 6.2 使用cgroup  详情 回复 发表于 2022-1-11 08:42
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-1-11 09:23 | 显示全部楼层
谢谢,我试试。前几天换的PVE6.4-13,原来用的7.0/7.1怎么都搞不定ppp拨号就换了。
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-2-15 15:49 | 显示全部楼层
是不是直接挂载/dev/ppp设备就可以拨号呀
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-3-24 13:13 | 显示全部楼层
大佬你好,替换sys.lua文件后路由状态页面一片空白、备份/升级页面错误代码。
请问这个怎么解决?谢谢

系统日志:
  1. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute firstchild dispatcher target for entry '/admin'.
  2. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: The called action terminated with an exception:
  3. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute function dispatcher target for entry '/admin/status'.
  4. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: The called action terminated with an exception:
  5. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute template dispatcher target for entry '/admin/status/overview'.
  6. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: The called action terminated with an exception:
  7. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/template.lua:97: Failed to execute template 'admin_status/index'.
  8. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: A runtime error occured: /usr/lib/lua/luci/sys.lua:95: attempt to call method 'string' (a nil value)
  9. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: stack traceback:
  10. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]:         [C]: in function 'assert'
  11. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]:         /usr/lib/lua/luci/dispatcher.lua:474: in function 'dispatch'
  12. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]:         /usr/lib/lua/luci/dispatcher.lua:126: in function </usr/lib/lua/luci/dispatcher.lua:125>
  13. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute firstchild dispatcher target for entry '/admin'.
  14. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: The called action terminated with an exception:
  15. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute function dispatcher target for entry '/admin/status'.
  16. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: The called action terminated with an exception:
  17. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute template dispatcher target for entry '/admin/status/overview'.
  18. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: The called action terminated with an exception:
  19. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/template.lua:97: Failed to execute template 'admin_status/index'.
  20. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: A runtime error occured: /usr/lib/lua/luci/sys.lua:95: attempt to call method 'string' (a nil value)
  21. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]: stack traceback:
  22. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]:         [C]: in function 'assert'
  23. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]:         /usr/lib/lua/luci/dispatcher.lua:474: in function 'dispatch'
  24. Thu Mar 24 09:43:47 2022 daemon.err uhttpd[1102]:         /usr/lib/lua/luci/dispatcher.lua:126: in function </usr/lib/lua/luci/dispatcher.lua:125>
  25. Thu Mar 24 09:43:48 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute template dispatcher target for entry '/admin/status/overview'.
  26. Thu Mar 24 09:43:48 2022 daemon.err uhttpd[1102]: The called action terminated with an exception:
  27. Thu Mar 24 09:43:48 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/template.lua:97: Failed to execute template 'admin_status/index'.
  28. Thu Mar 24 09:43:48 2022 daemon.err uhttpd[1102]: A runtime error occured: /usr/lib/lua/luci/sys.lua:95: attempt to call method 'string' (a nil value)
  29. Thu Mar 24 09:43:48 2022 daemon.err uhttpd[1102]: stack traceback:
  30. Thu Mar 24 09:43:48 2022 daemon.err uhttpd[1102]:         [C]: in function 'assert'
  31. Thu Mar 24 09:43:48 2022 daemon.err uhttpd[1102]:         /usr/lib/lua/luci/dispatcher.lua:474: in function 'dispatch'
  32. Thu Mar 24 09:43:48 2022 daemon.err uhttpd[1102]:         /usr/lib/lua/luci/dispatcher.lua:126: in function </usr/lib/lua/luci/dispatcher.lua:125>
  33. Thu Mar 24 09:43:58 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute template dispatcher target for entry '/admin/status/overview'.
  34. Thu Mar 24 09:43:58 2022 daemon.err uhttpd[1102]: The called action terminated with an exception:
  35. Thu Mar 24 09:43:58 2022 daemon.err uhttpd[1102]: /usr/lib/lua/luci/template.lua:97: Failed to execute template 'admin_status/index'.
  36. Thu Mar 24 09:43:58 2022 daemon.err uhttpd[1102]: A runtime error occured: /usr/lib/lua/luci/sys.lua:95: attempt to call method 'string' (a nil value)
  37. Thu Mar 24 09:43:58 2022 daemon.err uhttpd[1102]: stack traceback:
  38. Thu Mar 24 09:43:58 2022 daemon.err uhttpd[1102]:         [C]: in function 'assert'
  39. Thu Mar 24 09:43:58 2022 daemon.err uhttpd[1102]:         /usr/lib/lua/luci/dispatcher.lua:474: in function 'dispatch'
  40. Thu Mar 24 09:43:58 2022 daemon.err uhttpd[1102]:         /usr/lib/lua/luci/dispatcher.lua:126: in function </usr/lib/lua/luci/dispatcher.lua:125>
复制代码



备份/升级 页面
  1. /usr/lib/lua/luci/dispatcher.lua:474: Failed to execute call dispatcher target for entry '/admin/system/flashops'.
  2. The called action terminated with an exception:
  3. /usr/lib/lua/luci/template.lua:97: Failed to execute template 'admin_system/flashops'.
  4. A runtime error occured: [string "/usr/lib/lua/luci/view/admin_system/flashop..."]:1: attempt to call field 'mtds' (a nil value)
  5. stack traceback:
  6.         [C]: in function 'assert'
  7.         /usr/lib/lua/luci/dispatcher.lua:474: in function 'dispatch'
  8.         /usr/lib/lua/luci/dispatcher.lua:126: in function
复制代码





点评

/usr/lib/lua/luci/sys.lua:95 这个地方肯定有问题。不同版本的界面不能直接替换啊。只能编辑按页面说明修改  详情 回复 发表于 2022-3-28 09:13
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

 楼主| 发表于 2022-3-28 09:13 | 显示全部楼层
smdx 发表于 2022-3-24 13:13
大佬你好,替换sys.lua文件后路由状态页面一片空白、备份/升级页面错误代码。
请问这个怎么解决?谢谢

/usr/lib/lua/luci/sys.lua:95 这个地方肯定有问题。不同版本的界面不能直接替换啊。只能编辑按页面说明修改
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-4-9 21:34 | 显示全部楼层
修改后仍然无法读取实时信息……
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-8-29 10:02 | 显示全部楼层
22版本的op pve7按上面修改后,连接数还是空,有没有其它好用的一点,可以看到单ip的连接数是多少
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-8-29 12:04 | 显示全部楼层
pve7.2按上面修改后,还是全空
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

发表于 2022-9-19 16:44 | 显示全部楼层
smdx 发表于 2022-1-10 14:32
楼主你好,我把lxc.mount.entry = /dev/ppp dev/ppp none bind,optional,create=file,rw lxc.cgroup2.dev ...

请问有支持lxc的5.13内核下载地址吗?到处找不到内核下载,下了5.15内核,不稳定,经常重启。

点评

https://www.right.com.cn/forum/thread-8202412-1-1.html  详情 回复 发表于 2022-9-19 17:49
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-3-29 08:04

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表