2

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.

5
  • 1
    There is a typo in a couple of places: the file has eth0:0 and this should be only eth0 in both places where it appears. Jan 4 '18 at 17:43
  • This isn't a typo, this is virtual network interface, to make sure both IP addresses are on eth0 interface, but to be able to bind to them separately. For example, I have SOCKS proxy server, which I'd like to have outgoing traffic go through this 145.* address (it's british, and I wanted my PC to look British), so I set up proxy to use eth0:0 and this way I am sure all outgoing traffic will go through 145.* address. Please look at linuxconfig.org/configuring-virtual-network-interfaces-in-linux . Moreover, this actually worked for some time, even before I started playing with IPv6. Jan 5 '18 at 5:40
  • 1
    Today it's a typo. That format has been deprecated for many years and shouldn't be used anymore. Jan 5 '18 at 6:18
  • Ok, this helped, I commented out everything that referred to 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 with eth1 legit within Linux? Or should I somehow install virtual interface? And will e.g. nginx be able to listen on both eth0 and new eth1? Jan 5 '18 at 8:30
  • Nevermind, I managed it by just adding new iface eth0 inet static entry with just address and mask, and setting dante's external setting to IP address instead of eth0: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. Jan 5 '18 at 8:54
1

The format of specifying a network interface alias as interface:number has been deprecated in Linux for many years, and should not be used anymore (being deprecated, it may be removed in the future). Today, all of the IP addresses you may need are added directly to the interface, without the need for aliasing.

So you need to change eth0:0 to eth0. (And auto eth0 only needs to appear once.) You currently have:

auto eth0:0
iface eth0:0 inet static
    address 145.239.XXX.XXX
    netmask 255.255.255.255

This should instead be:

iface eth0 inet static
    address 145.239.XXX.XXX
    netmask 255.255.255.255

Applications which were configured to use the old-style interface alias should instead be set up to use the corresponding IP address, or to listen to all addresses, as appropriate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.