使用 MACVLAN 为主机同时分配静态 IP 并取得动态 IP
有了之前 pve 目录清空 的 PVE 目录又一次没了 的经验,管理端口不设置静态地址还是比较危险的。
但我还是想 让 DNSmasq 响应 DHCPv4 主机的 IPv6 地址,有个好主意,让主机网卡拥有多个 IP 地址。
-
一张网卡两个 IP
也就是 IP alias 技术,或者叫 secondary IP,挺常用的,在 通过网络连接到设备 也记录过。 -
两张网卡两个 IP
好处是可以用不同的 MAC 地址,在 DHCP 时能获得与静态不同的 IP。
auto enp5s0
iface enp5s0 inet manual
#Qualcomm Atheros Killer E2500 Gigabit Ethernet Controller
auto vmbr0
# 这里静态地址已经在 DHCP 上注册过了,重复一遍是为了在 DHCP 上产生解析记录
iface vmbr0 inet dhcp
iface vmbr0 inet static
address 192.168.9.17/24
bridge-ports enp5s0
bridge-stp off
bridge-fd 0
# 获得 SLAAC 地址
iface vmbr0 inet6 auto
# 通过 DHCP 获得一个地址
auto mgmt
iface mgmt inet dhcp
pre-up ip link add link vmbr0 name mgmt type macvlan mode bridge
post-down ip link del mgmt
# 获得 SLAAC 地址
iface mgmt inet6 auto对于使用 systemd-networkd 的可以参考这里 Configuring a second static IP with its own MAC address on an existing interface - ArchWiki
使用 SLAAC 获得长短两个 IPv6 地址
在配置了 IPv6 SLAAC 的环境里,比如 OpenWrt IPv6 Passthrough,我发现在启用 accept_ra 的基础上,再设置 inet6 auto 可以多获得个短地址。,
auto vmbr0
iface vmbr0 inet dhcp
post-up sysctl net.ipv6.conf.vmbr0.accept_ra=2
iface vmbr0 inet6 autoaccept_ra 设置为 1 或者 2 都行,这里设置为 2 是要在开启 ip_forward 的基础上也获得 SLAAC 地址
结果是这样,一个 /128 一个 /64
3: vmbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 1c:1b:0d:95:90:d1 brd ff:ff:ff:ff:ff:ff
inet 192.168.9.17/24 brd 192.168.9.255 scope global dynamic vmbr0
valid_lft 85372sec preferred_lft 85372sec
inet6 2409:8a1e:6940:36d0::3af/128 scope global dynamic
valid_lft 86396sec preferred_lft 86396sec
inet6 2409:8a1e:6940:36d0:1e1b:dff:fe95:90d1/64 scope global dynamic mngtmpaddr proto kernel_ra
valid_lft 257160sec preferred_lft 170760sec
inet6 fe80::1e1b:dff:fe95:90d1/64 scope link proto kernel_ll
valid_lft forever preferred_lft forever更可以用 VLAN 来分端口,可我手上没有支持 VLAN 的设备。
构建 ogimage 提示 unsupported opentype signature <!do 错误
在腾讯云构建 Pages 时,最近常在 ogimage.tsx 调用 satori 的部分失败,完整错误是 failed to emit from plugin `customogimages`: unsupported opentype signature <!do,之前出现过几次,但重试就好了。看结构像是 <!doctype html> 的一部分
failed to emit from plugin `customogimages`: unsupported opentype signature <!do
at generatesocialimage (../plugins/emitters/ogimage.tsx:52:15)
at processogimage (../plugins/emitters/ogimage.tsx:84:18)
at object.emit (../plugins/emitters/ogimage.tsx:120:9)
at ../processors/emit.ts:24:28
at async promise.all (index 10)
at emitcontent (../processors/emit.ts:18:3)添加日志后抓到了现场,是在通过 https://wget.la/github.com/dsrkafuu/misans/blob/main/raw/Normal/ttf/MiSans-Regular.ttf 下载 ttf 文件时,跳转到的 https://wget.la/GE/CC/VALIDATOR?key=19226b6c9951b5eff6b3dac1a5d9cc90.b925a18f442be92e8555611e10f38a92.1763474597&url=https%3A%2F%2Fwget.la%2Fhttps%3A%2F%2Fgithub.com%2Fdsrkafuu%2Fmisans%2Fblob%2Fmain%2Fraw%2FNormal%2Fttf%2FMiSans-Regular.ttf 响应 403 Forbidden,返回了个 HTML 网页提示 当前请求已被CC策略拦截。 相关代码在 Obsidian-Vault/patches/@jackyzha0__quartz@4.5.2.patch at 9c1ae0828daa0e4aa946e11eefdbfdd109b4a852 · enihsyou/Obsidian-Vault
看来是对来源 IP 做了拦截的样子,或者同一 IP 大量限流?毕竟是从服务器集群发出的请求。之前 GitHub Proxy 测速 得到 wget.la 最快,那退而求其次,选 gh-proxy.com
OpenWrt 支持注册 IPv6 解析
之前在 ASUS Merlin 固件上搞了 让 DNSmasq 响应 DHCPv4 主机的 IPv6 地址,其实就是加一行 dhcp-range=::,constructor:br0,ra-names 配置。但在 OpenWrt 上 dnsmasq.conf 是由 /etc/config/dhcp 生成的,那么得有个地方添加这个属性。
找遍了也没有比较直观的地方可以进行这个配置,那么诉诸自定义配置肯定可以。好在虽然文档上没有,Add Dnsmasq Custom Options field in LuCi GUI - For Developers - OpenWrt Forum 新增的 extraconftext 能承载任意文本。
uci set dhcp.@dnsmasq[0].extraconftext='enable-ra\ndhcp-range=::,constructor:br-lan,ra-names'
uci commit dhcp
/etc/init.d/dnsmasq restart不过光是 OpenWrt 支持这个属性还不够,得安装的 DNSmasq 支持 DHCPv6 才行,比如当前我的版本是这样,说明不支持
# dnsmasq --version
Dnsmasq version 2.90 Copyright (c) 2000-2024 Simon Kelley
Compile time options: IPv6 GNU-getopt no-DBus UBus no-i18n no-IDN DHCP no-DHCPv6 no-Lua TFTP no-conntrack no-ipset no-nftset no-auth no-cryptohash no-DNSSEC no-ID loop-detect inotify dumpfile而支持 ra-names 这套操作的主路由上版本是带 DHCPv6 的 2.91
# dnsmasq --version
Dnsmasq version 2.91 Copyright (c) 2000-2025 Simon Kelley
Compile time options: IPv6 GNU-getopt no-RTC no-DBus no-UBus no-i18n no-IDN DHCP DHCPv6 no-Lua TFTP no-conntrack ipset no-nftset no-auth DNSSEC no-ID loop-detect no-inotify no-dumpfile安装倒是简单,opkg install dnsmasq-dhcpv6 --force-overwrite,强制动作是用来移除旧的版本。然后按照 LXC 安装的 OpenWrt 在安装 dnsmasq-full 后无法启动 dnsmasq 的修正方式调整启动脚本。
记得按 OpenWrt IPv6 Passthrough 设置好 Passthrough 模式。