在 PVE 用 LXC 安装 OpenWrt
访问符合自己架构的下载页面选个最新 OpenWrt 版本。(也可以从速度更快的 Linux Containers - Image server 下载)
在 Linux Containers - Image server 找到符合自己架构的 OpenWrt 版本,比如我需要去 Index of /images/openwrt/24.10/amd64/default/ 中选个最新的日期。
注意不要使用 downloads.openwrt.org 的下载源,一定要用的话,请按照 LXC 安装的 OpenWrt 在安装 dnsmasq-full 后无法启动 dnsmasq 的说明,安装后修改系统文件。
里面会有多个文件,这里下载 LXC 支持的 rootfs.tar.xz 就好。不要选择 .img.gz 结尾的镜像文件,那个是给虚拟机用的。
$
$ pvesm status
Name Type Status Total Used Available %
local dir active 98497780 8796472 84651760 8.93%
local-lvm lvmthin active 808222720 33702887 774519832 4.17%
$ pvesm list local
Volid Format Type Size VMID
local:iso/iKuai8_x64_3.7.20_Build202506041743.iso iso iso 54763520
local:iso/ubuntu-25.04-live-server-amd64.iso iso iso 2021750784
local:vztmpl/alpine-3.22-default_20250617_amd64.tar.xz txz vztmpl 3271244
local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst tzst vztmpl 126515062
$ pvesm path local:vztmpl/debian-12-standard_12.7-1_amd64.tar.zst
/var/lib/vz/template/cache/debian-12-standard_12.7-1_amd64.tar.zst
$ wget -c -P /var/lib/vz/template/cache/ https://images.linuxcontainers.org/images/openwrt/24.10/amd64/default/20251027_11%3A57/rootfs.tar.xz
$ wget -c -P /var/lib/vz/template/cache/ https://downloads.openwrt.org/releases/24.10.4/targets/x86/64/openwrt-24.10.4-x86-64-rootfs.tar.gz接下来就是创建 LXC 了,按需调整参数,选择镜像文件
pct create 104 \
--description "Router for PVE subnet" \
--hostname openwrt --net0 name=eth0,bridge=vmbr0,ip=dhcp,ip6=auto --net1 name=eth1,bridge=vmbr1,ip=dhcp,ip6=auto \
--rootfs local-lvm:0.5 --arch amd64 --cores 1 --memory 512 \
--ostype unmanaged --arch amd64 /var/lib/vz/template/cache/openwrt-24.10.4-x86-64-rootfs.tar.gz
echo "lxc.include: /usr/share/lxc/config/openwrt.common.conf" >> /etc/pve/lxc/104.conf
pct start 104因为我的网络设置是计划让 OpenWrt 服务所有其他 VM 所在的子网:
vmbr0 - eth0 - wan 192.168.9.0/24上游连接 PVE 所在的主机网络vmbr1 - eth1 - lan 192.168.2.0/24下游连接 LXC 其他容器的虚拟网络
所以会需要从 WAN 口访问 LuCI 管理页面,得添加个防火墙配置。
# start a shell in lxc
pct enter 104
# create a new section of the rule in /etc/config/firewall
# allow http connection from WAN side
uci add firewall wan_https_allow
uci set firewall.wan_https_allow=rule
uci set firewall.wan_https_allow.name='Allow HTTP, HTTPS from WAN'
uci set firewall.wan_https_allow.src='wan'
uci set firewall.wan_https_allow.proto='tcp'
uci set firewall.wan_https_allow.dest_port='80 443'
uci set firewall.wan_https_allow.target='ACCEPT'
# allow ssh connection from WAN side
uci add firewall wan_ssh_allow
uci set firewall.wan_ssh_allow=rule
uci set firewall.wan_ssh_allow.name='Allow SSH from WAN'
uci set firewall.wan_ssh_allow.src='wan'
uci set firewall.wan_ssh_allow.proto='tcp'
uci set firewall.wan_ssh_allow.dest_port='22'
uci set firewall.wan_ssh_allow.target='ACCEPT'
# save the new section to /etc/config/firewall
uci commit firewall
# reload the firewall to pick up the new rule
/etc/init.d/firewall reload设置一下中国大陆 opkg 包镜像 OpenWRT 软件仓库镜像使用帮助 - MirrorZ Help
sed -i 's_https\?://downloads.openwrt.org_https://mirrors.cernet.edu.cn/openwrt_' /etc/opkg/distfeeds.conf
opkg update
opkg install luci-i18n-base-zh-cnLXC 中的 uptime 和 free 返回主机的信息
比如主机有 64GiB 内存,分配给 LXC 有 0.5 GiB,但在 free 中输出的是主机信息,没有读取容器应用的设置。Uptime 也是同理,显示主机的启动时间。
$ head -n3 /proc/meminfo
MemTotal: 65536 kB
MemFree: 2052 kB
MemAvailable: 47149 kB
$ free
total used free shared buff/cache available
Mem: 65725628 2303211 63027148 37312 395269 47145
Swap: 33554428 0 33554428- Incorrect results with uptime and free for alpine containers - Incus - Linux Containers Forum 也有人遇到过,不过没解决
- System call interception - Incus documentation 在 Incus 有 实现,但 PVE 用的是 LXC
- LXC 5 load averages are wrong in Debian 12 container · 议题 #4372 · lxc/lxc 给出了无奈的解决方向
受影响的有 Alpine 和 OpenWrt 实例,Ubuntu 没问题。因为它们俩用 sysinfo 系统调用来读取信息,而这部分不能被 LXCFS 重写。
或许可以参照 Incus 实现个 seccomp listner ?
Windows SSH 粘贴文字会丢失开头的一些字符
在 SSH 中使用右键,或者 Ctrl+Shift+V 粘贴剪切板里的文本到远程时,会丢失开头的前 10 位字符。
| 粘贴内容 | 表现结果 |
|---|---|
12345678901abcdef | 1abcdef |
a{b}c[d]e-f*g/h~i`j%k^l$m#n@o"p'q<r>s | f*g/h~i`j%k^l$m#n@o"p'q<r>s |
C:\Program Files\OpenSSH\ssh.exe | Files\OpenSSH\ssh.exe |
问题只发生在 Windows Terminal + PowerShell7 + C:\Program Files\OpenSSH\ssh.exe + busybox ash 上,VSCode、WSL、Git-Bash、CMD 使用同样的 SSH 就没有问题。
发现有人提过,但表现不一样,并且那边已经修复了。
刚在 Windows Terminal 终端仿真里不知道动了什么,居然没问题了。再观察下,挺好复现的
Edge 新标签页变成 ntp.msn.cn/edge/ntp
我目前的习惯是,想要 Google 搜索什么的时候,按 Ctrl+T 打开新标签页,开始在地址栏上键入关键字,按回车进行搜索。
其实更应该用 SurfingKeys 的
sg指令,快速用 Google 搜索剪贴板文字
可近期 Edge 新标签页一打开,会有短暂的一秒空白页,然后才跳转到真正的「新标签页面」。而这个跳转,会把地址栏上的内容清空掉 😠。经常就盲打途中发现之前输入的内容没了,要么清空再打一遍,要么重置光标再去补全,反正体验很差劲。
我通过开发者工具发现,打开空白新标签页的实际路径是这样的:
edge://newtab元链接,指示浏览器打开新选项卡页面https://ntp.msn.com/edge/ntp?locale=zh-CN&title=新建标签页&dsp=1&sp=Bing&feed_dis=off&en_widget_reg=false&PC=U531&adppc=EDGEESS
第一次 302 跳转,sp 参数对应在 在地址栏中使用的搜索引擎 设置的搜索引擎- 如果是 Bing,并且地理位置信息在中国大陆,会再次跳转到
ntp.msn.cn的相同地址,打开一个满是 MSN 广告的「个性化主页」,和 Windows 11 左下角任务栏小组件差不多。打开「MSN 智能探索 / MSN Copilot Discover」能好一些,但跳转的加载速度真的是慢。 - 如果是其他地区,会是国际版的
ntp.msn.com - 如果是其他搜索引擎,或者网络「不好」,比如我在 无法修改 Edge 浏览器搜索引擎地址中的地区信息 改成了 Google HK,则会来到比较干净的
chrome-search://local-ntp/local-ntp.html。可以按照 修改 Edge 的 New Tab Page 的最常访问网站 的方式修改常用网站链接。
现在我的需求就是,干净简洁,别瞎几把跳转,禁止中国大陆广告。
选择通过组策略直接修改新标签页为 chrome-search://local-ntp/local-ntp.html,修改的位置在 本子组策略编辑器 > 用户配置 > 管理模板 > Microsoft Edge > 启动、主页和新标签页 > 配置新的标签页 URL。这样就跳过了从互联网网页跳转的过程,省去建立网络链接等动作产生的等待白屏。
想法很美好,可现在的版本 140.0.3485.54,会提示「此策略被阻止,其值将被忽略。」,因为这个策略只在「受组管理的设备」上可用 😠,我都无法理解为什么微软会有这种限制,就这么想推广自己的 NewTab?
This policy is available only on Windows instances that are joined to a Microsoft Active Directory domain or Windows 10 Pro or Enterprise instances that are enrolled for device management.
此策略仅适用于已加入 Microsoft Active Directory 域、已加入 Microsoft Azure Active Directory 的 Windows 实例,或已注册设备管理的实例。在 macOS 上,此策略仅适用于通过 MDM 管理或已通过 MCX 加入域的实例。
这篇博文通过真地加入一个管理域,找到了 Edge 认为被 MDM 管理必须的几个关键注册表键,创建了一个假的 MDM 管理假象。导入第一个文件 MDM-FakeEnrollment-Win10.reg 即可,剩下的去组策略改。
Windows Registry Editor Version 5.00
; # Fake MDM-Enrollment - Key 1 of 2 - let a Win10 Machine "feel" MDM-Managed
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Enrollments\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF]
"EnrollmentState"=dword:00000001
"EnrollmentType"=dword:00000000
"IsFederated"=dword:00000000
; # Fake MDM-Enrollment - Key 2 of 2 - let a Win10 Machine "feel" MDM-Managed
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Provisioning\OMADM\Accounts\FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF]
"Flags"=dword:00d6fb7f
"AcctUId"="0x000000000000000000000000000000000000000000000000000000000000000000000000"
"RoamingCount"=dword:00000000
"SslClientCertReference"="MY;User;0000000000000000000000000000000000000000"
"ProtoVer"="1.2"Edge 使用安全的 DNS 显示托管浏览器禁用此设置
修改组策略会导致浏览器标记为「受组织管理」,禁止开启「安全的 DNS」。
但可以通过组策略开启 策略编辑器 > 用户配置 > 管理模板 > Microsoft Edge > 控制 DNS-over-HTTPS 的模式,设置为「启用不带不安全回退功能的 DNS-over-HTTPS」
OpenWrt IPv6 Passthrough
- 二级路由(openwrt)开启ipv6中继(ipv4和ipv6共存) – late哥哥笔记
- OpenWRT 路由器IPv6实战配置长篇教程:纠正你的IPv4思维!__什么值得买
- 【全网最细】ipv6工作流程详解,openwrt软路由配置ipv6教程,homeproxy、openclash代理ipv6流程,sing-box、mihomo,ipv6科学上网不冲突,ipv6代理
Version: OpenWrt 24.10.2 r28739-d9340319c6 / LuCI openwrt-24.10 branch 25.168.50434~d6b13f6
- WAN 接口 DHCP 服务器指定为主接口,至少开启 RA 中继,才能在 LAN 侧获得地址
- WAN6 接口,如果有大于/64 的地址块,勾上扩展前缀,获取 IPv6-PD 地址块
- LAN 接口 DHCP 服务器开启中继模式;
IPv6 分配长度 64,IPv6 后缀填 eui64,这样 LAN 口就有地址了
config interface 'wan'
option proto 'dhcp'
option device 'eth0'
config interface 'wan6'
option proto 'dhcpv6'
option device 'eth0'
option reqaddress 'try'
option reqprefix 'auto'
option norelease '1'
option extendprefix '1'
config interface 'lan'
option proto 'static'
option device 'br0'
option ipaddr '192.168.2.1'
option netmask '255.255.255.0'
config device
option type 'bridge'
option name 'br0'
list ports 'eth1'