I'm attempting to add IPv6 addresses for my clients. From my provider I got a fixed /64 IPv6 range, I want to subnet it into a /112 range for the OpenVPN clients (I will verify with my internet provider if there are any technical limitations with this idea). The subnetting idea came from several websites, including the OpenVPN documentation regarding IPv6 (all links listed below). My IPv4 setup is working perfectly for at least a year already. So that part is fully tested and functional. For the IPv6 IP allocation I want to use CCD, just like I do with IPv4.
Some explanation about the IP's and such.
2001:aaaa:bbbb:1::/64 = Subnet of my provider.
2001:aaaa:bbbb:1:10:1:1::/112 = Subnet I want to use for my OpenVPN clients (reachable for the world).
Furthermore, I have 2 tunnel configs. One for UDP and the other for TCP which is routed via my iptable config to use port 443 and share it with Apache. The UDP tunnel is what I use to test IPv6 + IPv4. The TCP tunnel is only IPv4 at the moment.
I use OpenVPN 2.4.0-6+deb9u2 on Raspbian 9 (Stretch) which is installed on a Raspberry Pi 3B+.
My TCP (IPv4 only) server config.
local 10.1.0.1
port 1194
port-share 127.0.0.1 443
proto tcp
dev tun
ca server/example.com/pki/ca.crt
cert server/example.com/pki/issued/vpn.example.com.crt
key server/example.com/pki/private/vpn.example.com.key
dh server/example.com/dh.pem
tls-auth server/example.com/ta.key 0
crl-verify server/example.com/pki/crl.pem
server 10.1.1.0 255.255.255.0
push "route 10.1.0.0 255.255.255.0"
client-config-dir server/example.com/ccd
ccd-exclusive
topology subnet
learn-address /usr/local/sbin/learn-address.sh
script-security 2
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 10.1.0.1"
push "dhcp-option DOMAIN home.lan"
push "dhcp-option DOMAIN home.vpn"
keepalive 10 30
remote-cert-tls client
auth SHA256
cipher AES-128-GCM
tls-cipher TLS-DHE-RSA-WITH-AES-128-GCM-SHA256
tls-version-min 1.2 or-highest
comp-lzo no
push "comp-lzo no"
user openvpn
group nogroup
persist-key
persist-tun
status /var/log/openvpn-status.log
log-append /var/log/openvpn.log
verb 3
sndbuf 0
rcvbuf 0
push "sndbuf 0"
push "rcvbuf 0"
My UDP (IPv4 + IPv6) server config. The indented stuff is added to the existing IPv4 config. The commented lines will be tested later.
local 10.1.0.1
#local 2001:aaaa:bbbb:1:10:1:0:1
port 1194
proto udp
#proto udp6
dev tun
ca server/example.com/pki/ca.crt
cert server/example.com/pki/issued/vpn.example.com.crt
key server/example.com/pki/private/vpn.example.com.key
dh server/example.com/dh.pem
tls-auth server/example.com/ta.key 0
crl-verify server/example.com/pki/crl.pem
server 10.1.1.0 255.255.255.0
server-ipv6 2001:aaaa:bbbb:1:10:1:1::/112
push "route 10.1.0.0 255.255.255.0"
push "route-ipv6 2001:aaaa:bbbb:1::/64"
push "route-ipv6 2000::/3"
client-config-dir server/example.com/ccd
ccd-exclusive
topology subnet
learn-address /usr/local/sbin/learn-address.sh
script-security 2
push "redirect-gateway def1 bypass-dhcp"
#push "redirect-gateway ipv6"
push "dhcp-option DNS 10.1.0.1"
push "dhcp-option DOMAIN home.lan"
push "dhcp-option DOMAIN home.vpn"
keepalive 10 30
remote-cert-tls client
auth SHA256
cipher AES-128-GCM
tls-cipher TLS-DHE-RSA-WITH-AES-128-GCM-SHA256
tls-version-min 1.2 or-highest
comp-lzo no
push "comp-lzo no"
user openvpn
group nogroup
persist-key
persist-tun
status /var/log/openvpn-status.log
log-append /var/log/openvpn.log
verb 5
sndbuf 0
rcvbuf 0
push "sndbuf 0"
push "rcvbuf 0"
My mobile phone uses this CCD config to receive a static IPv4 and IPv6 IP.
ifconfig-push 10.1.1.3 255.255.255.0
ifconfig-ipv6-push 2001:aaaa:bbbb:1:10:1:1:3/112 2001:aaaa:bbbb:1:10:1:1:1
eth0 is connected to the internet and is configured with a static IP.
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 10.1.0.1
netmask 255.255.255.0
gateway 10.1.0.10
dns-nameservers 10.1.0.1 10.1.0.10
dns-search home.lan home.vpn
iface eth0 inet6 static
address 2001:aaaa:bbbb:1:10:1:0:1
netmask 64
gateway gateway fe80::7eff:aaaa:bbbb:cccc
accept_ra 1
privext 2
This is in my sysctl.conf.
#kernel.domainname = example.com
#kernel.printk = 3 4 1 3
net.ipv4.conf.default.rp_filter=1
net.ipv4.conf.all.rp_filter=1
net.ipv4.tcp_syncookies=1
net.ipv4.ip_forward=1
#net.ipv6.conf.all.forwarding=1
#net.ipv4.conf.all.accept_redirects = 0
#net.ipv6.conf.all.accept_redirects = 0
#net.ipv4.conf.all.send_redirects = 0
#net.ipv4.conf.all.accept_source_route = 0
#net.ipv6.conf.all.accept_source_route = 0
net.ipv4.conf.all.log_martians = 1
#kernel.sysrq=1
#fs.protected_hardlinks=0
#fs.protected_symlinks=0
net.ipv4.tcp_rfc1337 = 1
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.all.proxy_ndp=1
Mijn mobiel die verbonden is via de UDP (IPv4 + IPv6) tunnel heeft alleen internet via IPv4. Ik zie in iptables geen drops, ook geen accepts for that matter in de FORWARD chain. Client en server kunnen elkaar niet pingen, internet connectie via IPv6 is voor de client ook niet mogelijk.
My phone gets the IPv4 and IPv6 IP's, but connectivity is only possible with IPv4. I don't see any ip6table drops or accepts for that matter (not in INPUT or FORWARD). The client and server can't ping each other.
These are the blogs/manuals I consulted.
https://community.openvpn.net/openvpn/wiki/IPv6
https://blog.apnic.net/2017/06/09/using-openvpn-ipv6/
https://cuzimageek.wordpress.com/2016/09/21/openvpn-and-ipv6/
https://feeding.cloud.geek.nz/posts/ipv6-and-openvpn-on-linode/
https://techblog.synagila.com/2016/02/24/build-a-openvpn-server-on-ubuntu-to-provide-a-ipv6-tunnel-over-ipv4/
https://blog.kmp.or.at/ipv6-enabled-openvpn/
https://tomsalmon.eu/2013/04/openvpn-ipv6-with-tun-device/
https://blog.angenieux.info/linux/serveur/openvpn-ipv4-ipv6-nat-sans-ndp/
https://forums.openvpn.net/viewtopic.php?t=21051
https://www.bjoerns-techblog.de/2017/07/openvpn-und-ipv6/
My guess is that I'm missing a routing option, here is a relevant snippet of my openvpn.log.
rWRwRwRwRwRSat Aug 4 13:48:51 2018 us=319238 intrepid.home.vpn/62.251.111.222:44356 MULTI: bad source address from client [10.1.0.13], packet dropped
RwRSat Aug 4 13:48:52 2018 us=640405 intrepid.home.vpn/62.251.111.222:44356 MULTI: bad source address from client [2001:aaa:bbbb:1:10:1:1:3], packet dropped