I have a tunnel set up between my laptop and server, using OpenVPN 2.3.10 on the client and 2.3.13 on the server. It was originally set up for IPv4 to masquerade my IP address to be my server IP address and to hide where I am connecting to from my local ISP. Then I added IPv6 so it is now dual-stack. I used masquerading with IPv6 to keep things as simple as I believed they could be.
My laptop setup and info:
lt1/pdh /home/pdh 1> cat /etc/issue.net
Ubuntu 16.04.1 LTS
lt1/pdh /home/pdh 2> uname -r
4.4.0-57-generic
lt1/pdh /home/pdh 3> ifconfig tun2kepler
tun2kepler Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:192.0.2.2 P-t-P:192.0.2.1 Mask:255.255.255.255
inet6 addr: fdff::2/64 Scope:Global
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1280 Metric:1
RX packets:425555 errors:0 dropped:0 overruns:0 frame:0
TX packets:386998 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:296698202 (296.6 MB) TX bytes:56672484 (56.6 MB)
My server setup and info:
kepler/phil /home/phil 1> cat /etc/issue.net
Ubuntu 14.04.5 LTS
kepler/phil /home/phil 2> uname -r
3.13.0-101-generic
kepler/phil /home/phil 3> ifconfig tun2home
tun2home Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
inet addr:192.0.2.1 P-t-P:192.0.2.2 Mask:255.255.255.255
inet6 addr: fdff::1/64 Scope:Global
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1280 Metric:1
RX packets:6730209 errors:0 dropped:0 overruns:0 frame:0
TX packets:7546625 errors:0 dropped:3158 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:835431595 (835.4 MB) TX bytes:5118239922 (5.1 GB)
Everything works including IPv6. The problem that I am having is that my browser and other clients are using IPv4. I want them to use IPv6 in cases where IPv6 can be used (DNS has an AAAA record and/or /etc/hosts has an IPv6 address). If there is only an IPv6 address then it works as long as that address is reachable and valid. But if there is an IPv4 address, then it gets used. I want it to prefer IPv6. So I googled for this an found suggestions to modify the /etc/gai.conf
file to change the precedence so IPv4 is lower. Here is that file:
# # #
precedence ::1/128 50
precedence ::/0 40
precedence 2002::/16 30
precedence ::/96 20
precedence ::ffff:0:0/96 12
precedence fec0::/10 10
precedence fc00::/7 19
precedence 2001:0::/32 18
# # #
label ::1/128 0
label ::/0 1
label 2002::/16 2
label ::/96 3
label ::ffff:0:0/96 4
label fec0::/10 4
label fc00::/7 4
label 2001:0::/32 4
# # #
So the precedence of IPv4 is 12 and most of IPv6 is higher? Is this a correct setting? What do I need to change to make my laptop prefer IPv6 when it can? I realize there may be cases where I should prefer IPv4 instead of IPv6, but I can't even get that problem. I would like to have other IPv6-enabled clients prefer IPv6 host-wide, as well, if possible.