简单记录一下杜甫折腾ipv6踩坑版

由 copilot 生成

最近在狗云的杜甫上折腾 PVE9 的 IPv6,踩了不少坑,整理一份可用的方案,简单操作。

背景

  • 支持 ipv6 的杜甫,通过都是**/64**
  • 已经安装 PVE 了,版本关系不大
  • 我只想给 windows 配置独立的 ipv6,访问部分网站 😂

配置

PVE 网卡配置

节选了核心配置如下

auto vmbr0
iface vmbr0 inet static
    address 119.30.30.30
    netmask 255.255.255.128
    gateway 119.30.30.1
    dns-nameservers 8.8.8.8 8.8.4.4
    bridge-ports ens3f0
    bridge-sftp off
    bridge-fd 0

iface vmbr0 inet6 static
    address 2402:4e00:666:6666::2
    gateway 2402:4e00:666:6666::

auto vmbr1
iface vmbr1 inet static
    address 192.168.11.1
    netmask 255.255.255.0
    bridge-ports none
    bridge-stp off
    bridge-fd 0
    post-up echo 1 > /proc/sys/net/ipv4/ip_forward
    post-up echo 1 > /proc/sys/net/ipv4/conf/vmbr1/proxy_arp
    post-up iptables -t nat -A POSTROUTING -s '192.168.11.0/24' -o vmbr0 -j MASQUERADE
    post-down iptables -t nat -D POSTROUTING -s '192.168.11.0/24' -o vmbr0 -j MASQUERADE

iface vmbr1 inet6 static
    address 2402:4e00:666:6666::1
    netmask 64
    post-up sysctl -w net.ipv6.conf.all.forwarding=1
    post-up sysctl -w net.ipv6.conf.all.proxy_ndp=1

配置完成后,加载一下

ifreload -a

配置相关

开启 IPv6 转发

cat > /etc/sysctl.d/99-ipv6.conf <<EOF
net.ipv4.ip_forward=1 
net.ipv6.conf.all.forwarding=1 
net.ipv6.conf.default.forwarding=1 
net.ipv6.conf.all.proxy_ndp=1 
net.ipv6.conf.vmbr0.proxy_ndp=1 
EOF

sysctl --system

配置 NDP 代理

安装 ndppd

apt update 
apt install ndppd

配置 ndppd

cat /etc/ndppd.conf
route-ttl 30000

proxy vmbr0 {
    router yes
    timeout 500
    ttl 30000

    rule 2402:4e00:666:6666::/64 {
        static
    }
}

启动服务

systemctl enable --now ndppd

ipv4 dhcp

简单来说,使用 dnsmasq

# 安装
apt install dnsmasq
# 配置
cat /etc/dnsmasq.d/vmbr1.conf
interface=vmbr1
bind-interfaces
dhcp-range=192.168.11.100,192.168.11.200,255.255.255.0,12h
dhcp-option=3,192.168.11.1
dhcp-option=6,8.8.8.8,8.8.4.4

# 启动
systemctl enable dnsmasq --now

虚拟机配置

ipv4 可以 dhcp,ipv6 手动配置(其实 ipv6 也可以 dhcp,利用 SLAAC)

虚拟机需要开启 ipv6 支持,大部分情况可能没开启,手动开启一下

sysctl -w net.ipv6.conf.all.disable_ipv6=0

网卡手动配置一下 ipv6

# The primary network interface
allow-hotplug ens18
iface ens18 inet dhcp

#iface ens18 inet6 auto
iface ens18 inet6 static
    address 2402:4e00:666:6666::326/64
    gateway 2402:4e00:666:6666::1

然后重启一下网卡,然后验证

curl test.ipw.cn

总结一下

其实还是挺简单,就是记录一下,方便后续重装哈哈哈

Sponsor

Like this article? $1 reward

Comments