Debian

OpenVPN IPv6 通過伺服器路由流量

  • January 27, 2019

我正在嘗試設置一個 OpenVPN 伺服器來通過它傳輸我的所有流量(IPv4 和 IPv6)。

伺服器是 Debian 8 並且有一個本地 IPv6 /64 子網:2a00:xxxx:35:59::/64

我想為我的 VPN 使用 /112 子網:2a00:xxxx:35:59::1:0/112

net.ipv6.conf.all.forwarding=1已啟用。

伺服器配置:

port 1194
proto udp6
dev tun
ca ca.crt
cert server.crt
key server.key
dh dh4096.pem
server 192.168.56.0 255.255.255.0
ifconfig-pool-persist ipp.txt
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"
duplicate-cn
keepalive 10 120
cipher AES-256-CBC
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
verb 3
auth SHA512
tls-cipher TLS-DHE-RSA-WITH-AES-256-GCM-SHA384:TLS-DHE-RSA-WITH-AES-128-GCM-SHA256:TLS-DHE-RSA-WITH-AES-256-CBC-SHA:TLS-DHE-RSA-WITH-CAMELLIA-256-CBC-SHA:TLS-DHE-RSA-WITH-AES-128-CBC-SHA:TLS-DHE-RSA-WITH-CAMELLIA-128-CBC-SHA
client-cert-not-required
auth-user-pass-verify /etc/openvpn/user-auth.py via-env
script-security 3

server-ipv6 2a00:xxxx:0035:0059::1:0/112
ifconfig-ipv6 2a00:xxxx:0035:0059::1:1 2a00:xxxx:0035:0059::1:2
tun-ipv6
push "redirect-gateway def1 bypass-dhcp"
push "route-ipv6 2000::/3"

在沒有push "route-ipv6 2000::/3"IPv4 流量的情況下,我可以通過 IPv4/IPv6 ping/訪問伺服器。使用此選項,這些都不起作用。

我認為這是一個路由問題,我已經嘗試過各種 iptables 配置(http://pastebin.com/erPPu2Nj),但沒有一個有效..

顯然 OpenVPN-2.3.*-client 有一個錯誤,阻止他使用新的預設 IPv6 路由。感謝 Gert 實現了這一點,並在郵件列表中告訴了我這一點!

為了讓我的 IPv6 用於隧道,我必須添加這些 iptables 設置:

ip6tables -I FORWARD -i tun0 -o eth0 -s 2a00:xxxx:35:59::1:0/112 -m conntrack --ctstate NEW -j ACCEPT
ip6tables -I FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
ip6tables -t nat -I POSTROUTING -o eth0 -s 2a00:xxxx:35:59::1:0/112 -j MASQUERADE

引用自:https://unix.stackexchange.com/questions/311699