Wednesday, July 16, 2008

Configuring IPv6 in CentOS Linux

To configure an IPv6 address manually into your CentOS Linux, there are several files that you can choose to change to:

/etc/sysconfig/networking/profiles/default/ifcfg-eth0
/etc/sysconfig/networking/devices/ifcfg-eth0
/etc/sysconfig/network-scripts/ifcfg-eth0


Choose only one from those files and add the following lines:

IPV6INIT=yes
IPV6ADDR=2001:db8:1234:5678:0001:0002:dead:beef/64

Then, restart your network interface for changes to take effect:

#/etc/init.d/network restart
or
#service network restart

Check your interface configuration:

# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0c:29:cf:3f:18
inet addr:192.168.1.101 Bcast:192.168.1.255 Mask:255.255.255.0
---> inet6 addr: 2001:db8:1234:5678:0001:0002:dead:beef/64 Scope:Global
inet6 addr: fe80::20c:29ff:fecf:3f18/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4344229 errors:0 dropped:0 overruns:0 frame:0
TX packets:1734857 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2992698082 (2.7 GiB) TX bytes:102015418 (97.2 MiB)
Interrupt:217 Base address:0x400

Observe the line pointed by the arrow, you have now a global IPv6 address.

IPv6 Documentation Prefix


The IPv6 prefix 2001:db8::/32 that we used in this article is for documentation or experimentation purposes only. But you can still use this address in your local network if you like. If you want more information about this prefix you can visit APNIC's FAQ about IPv6 Documentation Prefix or read RFC 3849: IPv6 Address Prefix Reserved for Documentation.


Enabling IPv6 in CentOS Linux

Usually, IPv6 is enabled by default during installation. But there are times that we want to take control of things manually... just like enabling or disabling IPv6 support in CentOS Linux. Some folks out there may feel that they don't need IPv6 yet and so they turn it off. Some have disabled IPv6 by default during installation but suddenly become curious about IPv6 and want to explore it, I hope this article could be of help.

The IPv6 knob in CentOS can be found at:
/etc/sysconfig/network

If you open it and your system supports IPv6 then it will look like this:
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=localhost.localdomain

If you don't see the "NETWORKING_IPV6=yes" in your "/etc/sysconfig/network" file, that means you have not enabled IPv6 yet. Or, if you have an IPv6 support and you want to turn it off, you just change "NETWORKING_IPV6" to "no".

You then need to restart your system for changes to take effect.