最近BGP Session和IPV6玩上瘾了,感觉万物都能套一个IPV6。
正好入手了NOCIX家的$20/m的堪萨斯远古辣鸡。闲来无事,那就记录一下。
本教程适合任何带有公网IPV4的独立服务器,VPS等X86构架的设备。
你和服务器需要具备:
1.独立公网IPV4
2.需要支持虚拟化
3.一段/64 IPV6地址(这里是因为我有ASN和/48的IPV6 所以我自己可以给自己分发,一般支持IPV6的商家都会给个/64,毕竟这玩意真的不值钱。没错就是你GreenCloud抠门只给/112 如果你机器没有IPV6但是你想和我一样,那欢迎找我PY IPV6地址,我这里很多啦)
3.Proxmox 6的性能要求
4.解决问题的耐心
2021.12.25更新:
现在可以直接安装Proxmox7来进行设置。
过程:
安装Proxmox 6
这部分应该很简单,无论是iso还是netboot亦或者Debian10直接升级为Proxmox6都是可以的。直接贴个大佬的教程。这里就不在赘述了。
https://www.vipkj.net/post-3656.html
Proxmox7安装教程
https://www.geekn.net/276.html
注:大陆机器因为网络问题可能Proxmox源连通性有问题。更换为以下的清华镜像即可。
nano /etc/apt/sources.list # pve6 <--> debian buster #deb http://ftp.debian.org/debian buster main contrib #deb http://ftp.debian.org/debian buster-updates main contrib # security updates #deb http://security.debian.org buster/updates main contrib # https needs(apt install apt-transport-https -y) deb https://mirrors.aliyun.com/debian buster main contrib non-free deb https://mirrors.aliyun.com/debian buster-updates main contrib non-free deb https://mirrors.aliyun.com/debian-security buster/updates main contrib non-free # pve6 repository: pve-no-subscription #deb http://download.proxmox.com/debian/pve buster pve-no-subscription #deb https://mirrors.ustc.edu.cn/proxmox/debian/pve buster pve-no-subscription deb http://download.proxmox.wiki/debian/pve buster pve-no-subscription
nano /etc/apt/sources.list # pve7 <--> debian bullseye # deb https://deb.debian.org/debian bullseye main deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription deb https://deb.debian.org/debian bullseye main non-free contrib deb-src https://deb.debian.org/debian bullseye main non-free contrib deb https://deb.debian.org/debian-security bullseye-security main deb-src https://deb.debian.org/debian-security bullseye-security main # bullseye-updates, to get updates before a point release is made; # see https://www.debian.org/doc/manuals/debian-reference/ch02.en.html#_updates_and_backports deb https://deb.debian.org/debian bullseye-updates main contrib non-free deb-src https://deb.debian.org/debian bullseye-updates main contrib non-free # bullseye-backports, previously on backports.debian.org deb https://deb.debian.org/debian bullseye-backports main contrib non-free deb-src https://deb.debian.org/debian bullseye-backports main contrib non-free
为什么不直接Debian11装Proxmox7呢。
经过测试,Proxmox7对于SIT隧道暂时无法支持,也就是说我的IPV6无法直接通过Proxmox7播到服务器上。所以只能先安装Proxmox6 然后通过更新的方式升级到Proxmox7,曲线救国花里胡哨。希望后期可以修复这个问题
配置网卡桥接
装好Proxmox6之后,同时我也默认SIT隧道配置成功,同时拥有了IPV6,那么我们就继续设置桥接网卡。
nano /etc/network/interfaces
source /etc/network/interfaces.d/* auto lo iface lo inet loopback allow-hotplug enp2s0 iface enp2s0 inet manual auto vmbr0 iface vmbr0 inet static address 142.54.165.2/29 netmask 255.255.255.248 gateway 142.54.165.1 bridge-ports enp2s0 bridge-stp off bridge-fd 0 dns-nameservers 8.8.8.8 auto vmbr1 iface vmbr1 inet static address 192.168.0.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 iptables -t nat -A POSTROUTING -s '192.168.0.0/24' -o vmbr0 -j MASQUERADE post-down iptables -t nat -D POSTROUTING -s '192.168.0.0/24' -o vmbr0 -j MASQUERADE iface vmbr1 inet6 static address 2a0f:5707:abe0:2::1 netmask 64 bridge_ports tun0 bridge_stp off bridge_fd 0 auto tun0 iface tun0 inet6 v4tunnel address 2a0f:5707:abe0:1::1 netmask 64 endpoint 192.3.51.1 local 142.54.165.1 ttl 255 mtu 1280 gateway 2a0f:5707:abe0:1::2
只要上面照猫画虎就好了。
tun0是我的隧道端配置,如果使用自己的IPV6就不需要这一块了。
配置DHCPv4 / DHCPv6 + SLAAC
因为IPV6没有网关这个概念,所以需要SLAAC来无感分配IPV6,只不过大部分人对于这个词并不了解,所以大家都统称为DHCP了。
首先安装软件:
apt install isc-dhcp-server radvd -y
DHCP服务于V4和V6,文件是/etc/default/isc-dhcp-server
nano /etc/default/isc-dhcp-server
加入内网所在网卡:
INTERFACESv4="vmbr1" INTERFACESv6="vmbr1"
DHCPv4为内网网段,文件是/etc/dhcp/dhcpd.conf
nano /etc/dhcp/dhcpd.conf
subnet 192.168.0.0 netmask 255.255.255.0 { option routers 192.168.0.1; option subnet-mask 255.255.255.0; option domain-name-servers 8.8.8.8; range 192.168.0.2 192.168.0.100; }
DHCPv6为我自己播的IPV6前缀,文件是/etc/dhcp/dhcpd6.conf. (是下发端,不是连接端。
nano /etc/dhcp/dhcpd6.conf
subnet6 2a0e:d487:ffff:12::/64 { range6 2a0f:5707:abe0:2::2 2a0f:5707:abe0:2:ffff:ffff:ffff:ffff; }
SLAAC下发IPV6,俗称DHCP IPV6:
nano /etc/radvd.conf
{ AdvSendAdvert on; MinRtrAdvInterval 30; MaxRtrAdvInterval 100; prefix 2a0f:5707:abe0:2::1/64 { AdvOnLink on; AdvAutonomous on; AdvRouterAddr on; }; };
SLAAC设置为开机自启:
stemctl enable isc-dhcp-server systemctl enable radvd
最后reboot 重启一下,就完成了开机的准备工作了。
不管是KVM还是LCX都可以nat IPV4和独立IPV6了。
2021.9.18更新
如果NAT和IPV6在小鸡上不通,要考虑转发模块没有打开。
nano /etc/sysctl.conf
net.core.default_qdisc = fq net.ipv4.tcp_congestion_control = bbr net.ipv4.ip_forward=1 net.ipv4.conf.default.rp_filter=2 net.ipv4.conf.all.rp_filter=2 net.ipv6.conf.default.forwarding=1 net.ipv6.conf.all.forwarding=1
最后sysctl -p
应用一下
大佬 我正需要这个教程 ,但是/etc/dhcp/dhcpd6.conf 这一句下面的ipv6我不知道怎么填,主机商给了我::1/64的ip段 我该怎么填这个,ipv4我都懂,就是全文v6配置这块完全懵逼
https://hostloc.com/forum.php?mod=viewthread&tid=891159&highlight=proxmox
可以看看这个教程。
如果你需要的话我可以分你两段V6这样你就可以不用依赖服务商V6了
我教程看了也没明白这两句哪里获得
subnet6 2a0e:d487:ffff:12::/64 {
range6 2a0e:d487:f00e:12::2 2a0e:d487:f00e:12:ffff:ffff:ffff:ffff;
比如说我的ip段是2664:abc0:1234:79::1/64
是用什么软件分吗
嗯 开独立IPV6小鸡需要你有两段/64,这两段12:/64和11:/64是我自己给自己下发的。所以我并不需要服务商给我下发IPV6地址段。你可以工单询问服务商,让他再给你一段/64就好了。如果他不给你,那你只能看看之前给你的回复中的教程,有单IPV6段的开小鸡方法。我这边都是以我自己播ipv6为基础的教程