### How to set a static IPv6 address on my Linux server? ###


The IP configuration of a host is a rather repetitive and - let's be honest - boring task. That's why the IPv6 protocol came up with a native mechanism called "stateless autoconfiguration". This mechanism allows an IPv6 client to autoconfigure itself, using some bits of informations provided by the local IPv6 gateway. That is, at least for the "IP" and "gateway" parameters (and few others, too, like MTU...). The gateway's IP is retrieved from broadcasts sent by the gateway (so called "Router Announcements"), and the host's IP is computed using the IPv6 prefix of the network (also retrieved from router announcements) combined to the MAC address of the ethernet card connected to the network.
However, there are cases when this mechanism might be dangerous. One of such case are addresses assigned to servers. If you let your server to autoconfigure itself, and then provide a DNS record pointing at this autoconfigured address, you will brake access to your server everytime that you change the network card of the server. Of course, you might say that if you change the network card of your server, you will update also the server's DNS record... but keep in mind that changing a DNS record can take a long time (depending of the TTL of your records), and - you will probably forget to update it anyway.

A good practice is to set the IPv6 address of your server statically. Setting the IPv6 address of a Linux host in a static way is highly dependent of the Linux distribution you're using. On a Debian machine, you would have to add such entry into /etc/network/interfaces:

 iface eth0 inet6 static
        pre-up modprobe ipv6
        address 2001:470:d37b:1::2
        gateway 2001:470:d37b:1::1
        netmask 64

Of course, you need to modify addresses according to your network. Note that the "pre-up" stanza was required in my case, because the ipv6 kernel module isn't loaded yet when the network configuration is read.

Usually, you will also want to prevent your network interface to get an autoconfigured IPv6 address (otherwise you would end up with two addresses: your static one and the autoconfigured one, which is rarely wanted).
In theory, it should be possible to disable IPv6 autoconfiguration by disabling following systctl settings:

 net.ipv6.conf.all.autoconf=0
 net.ipv6.conf.all.accept_ra=0

Unfortunately, this hasn't worked on my Debian 5.0.6 server, so I just disabled router annoucements on my router.