Configure IPv6 on your Linux system (Ubuntu)

After the presentation on IPv6 at the first event of the Emtel Knowledge Series and some recent discussion on social media networks with other geeks and Linux interested IT people here in Mauritius, I thought that I should give it a try (finally) and tweak my local network infrastructure. Honestly, I have been to busy with contractual project work and it never really occurred to me to set up IPv6 in my LAN. Well, the following paragraphs are going to shed some light on those aspects of modern computer and network technology.

This is the first article in a series on IPv6 configuration:

Piece of advice: This is based on my findings on the internet while reading other people's helpful articles and going through a couple of man-pages on my local system.

Let's embrace IPv6

The basic configuration on Linux is actually very simple as the kernel, operating system, and user-space programs support that protocol natively. If your system is ready to go for IP (aka: IPv4), then you are good to go for anything else. At least, I didn't have to install any additional packages on my system(s). We are going to assign a static IPv6 address to the system. Hence, we have to modify the definition of interfaces and check whether we have an inet6 entry specified. Open your favourite text editor and check the following entries (it should be at least similar to this):

$ sudo nano /etc/network/interfaces

auto eth0
# IPv4 configuration
iface eth0 inet static
  address 192.168.1.2
  network 192.168.1.0
  netmask 255.255.255.0
  broadcast 192.168.1.255

# IPv6 configuration
iface eth0 inet6 static
  pre-up modprobe ipv6
  address 2001:db8:bad:a55::2
  netmask 64

Of course, you might have to adjust your interface device (eth0) or you might be interested to have multiple directives for additional devices (eth1, eth2, etc.). The auto instruction takes care that your device is enabled and configured during the booting phase. The use of the pre-up directive depends on your kernel configuration but in most scenarios this might be an optional line. Anyways, it doesn't hurt to have it enabled after all - just to be on the safe side.

Next, either restart your network subsystem like so:

$ sudo service networking restart

Or you might prefer to do it manually with identical parameters, like so:

$ sudo ifconfig eth0 inet6 add 2001:db8:bad:a55::2/64

In case that you're logged in remotely into your PC (ie. via ssh), it is highly advised to opt for the second choice and add the device manually.

You can check your configuration afterwards with one of the following commands (depends on whether it is installed):

$ sudo ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:21:5a:50:d7:94  
          inet addr:192.168.160.2  Bcast:192.168.160.255  Mask:255.255.255.0
          inet6 addr: fe80::221:5aff:fe50:d794/64 Scope:Link
          inet6 addr: 2001:db8:bad:a55::2/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

$ sudo ip -6 address show eth0
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
    inet6 2001:db8:bad:a55::2/64 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::221:5aff:fe50:d794/64 scope link 
       valid_lft forever preferred_lft forever

In both cases, it confirms that our network device has been assigned a valid IPv6 address.

That's it in general for your setup on one system. But of course, you might be interested to enable more services for IPv6, especially if you're already running a couple of them in your IP network. More details are available on the official Ubuntu Wiki.

Continue to configure your network to provide IPv6 address information automatically in your local infrastructure.