For some time I am struggling with configuration of IPv6 in my Ubuntu VPS. I followed many tutorials on this matter, but none worked for me. The problem is, when I use one-time configuration in console:
ip addr add 2001:41D0:401:3000::XXXX/128 dev eth0
ip -6 route add 2001:41D0:401:3000::1 dev eth0
ip -6 route add default via 2001:41D0:401:3000::1 dev eth0
Everything is OK (of course I replaced last part of my IP with XXXX
).
However when I tried to put these into my /etc/network/interfaces
, after reboot I am left with only autoconfig IPv6 address.
No matter what I tried to enter into this file, what I get on ip addr show eth0
(eth0
is my interface) is:
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether fa:16:3e:7e:48:85 brd ff:ff:ff:ff:ff:ff
inet 164.132.XXX.XXX/32 brd 164.132.XXX.XXX scope global eth0
valid_lft forever preferred_lft forever
inet 145.239.XXX.XXX/32 brd 145.239.XXX.XXX scope global eth0:0
valid_lft forever preferred_lft forever
inet6 fe80::f816:3eff:fe7e:4885/64 scope link
valid_lft forever preferred_lft forever
I have 2 IPv4 addresses, and they both work, but I'd love to have IPv6 too. I have one assigned by OVH.
Here's my /etc/network/interfaces
:
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 164.132.XXX.XXX
netmask 255.255.255.255
post-up /sbin/ip route add 164.132.XXX.1 dev eth0
post-up /sbin/ip route add default via 164.132.XXX.1
post-up /sbin/ifconfig eth0:0 145.239.XXX.XXX netmask 255.255.255.255 broadcast IP_FAIL_OVER
pre-down /sbin/ifconfig eth0:0 down
pre-down /sbin/ip route del default via 164.132.XXX.1
pre-down /sbin/ip route del 164.132.XXX.1 dev eth0
dns-nameserver 213.186.33.99
dns-search ovh.net
iface eth0 inet6 static
address 2001:41D0:401:3000::XXXX
netmask 128
post-up /sbin/ip -6 route add 2001:41D0:401:3000::1 dev eth0
post-up /sbin/ip -6 route add default via 2001:41D0:401:3000::1 dev eth0
pre-down /sbin/ip -6 route del default via 2001:41D0:401:3000::1 dev eth0
pre-down /sbin/ip -6 route del 2001:41D0:401:3000::1 dev eth0
auto eth0:0
iface eth0:0 inet static
address 145.239.XXX.XXX
netmask 255.255.255.255
I also tried adding IPv6 like this:
iface eth0 inet6 static
address 2001:41D0:401:3000::XXXX
netmask 128
gateway 2001:41D0:401:3000::1
and with full (expanded) IP addresses, but without any success.
Also added
net.ipv6.conf.eth0.autoconf=0
net.ipv6.conf.default.autoconf=0
net.ipv6.conf.all.autoconf=0
net.ipv6.conf.eth0.accept_ra=0
to my sysctl.conf, as OVH tutorial and some other suggested, but it didn't change anything, whether it was there or not.
Between each check I rebooted whole machine, to make sure all configs were reloaded, and as service networking restart
fails with
sty 04 15:54:21 vpsXXXXXX.ovh.net ifup[2426]: RTNETLINK answers: File exists
sty 04 15:54:21 vpsXXXXXX.ovh.net ifup[2426]: Failed to bring up eth0.
sty 04 15:54:21 vpsXXXXXX.ovh.net ifup[2426]: RTNETLINK answers: File exists
sty 04 15:54:21 vpsXXXXXX.ovh.net ifup[2426]: Failed to bring up eth0:0.
sty 04 15:54:21 vpsXXXXXX.ovh.net systemd[1]: networking.service: Main process exited, code=exited, status=1/FAILURE
sty 04 15:54:21 vpsXXXXXX.ovh.net systemd[1]: Failed to start Raise network interfaces.
Thank you very much for all your help and I will be glad to provide more information if needed.
eth0:0
and this should be onlyeth0
in both places where it appears.eth0:0
and after reboot my IPv6 address shown up. Please feel free to add it as answer, so I can mark it as correct. However, I'd love to know, how to make by second IPv4 address work? I'd love to be able to make sure my dante proxy uses it for outgoing traffic, but it would be also nice if other services could listen on both IPv4 addresses. Is adding just entry witheth1
legit within Linux? Or should I somehow install virtual interface? And will e.g. nginx be able to listen on botheth0
and neweth1
?iface eth0 inet static
entry with just address and mask, and setting dante'sexternal
setting to IP address instead ofeth0:0
interface. Now everything works and I have nice IPv6 address :) Thank you for your help. Please add an answer, to make sure solution is visible if anybody would have same problems - OVH still lists virtual interface as solution to adding more IP addresses to machine.