Red Hat / CentOS IPv6 Network Configuration

by on January 23, 2009 · 22 comments· LAST UPDATED April 5, 2009

in , ,

Q. How do I configure static IPv6 networking under RHEL 5.x / Fedora / CentOS Linux?

A. Red Hat / CentOS / Fedora RHEL support IPv6 out of box. All you have to do is update two files and turn on networking.

You need to update and configure following files for IPv6 configuration:

  1. /etc/sysconfig/network : Turn on networking in this file.
  2. /etc/sysconfig/network-scripts/ifcfg-eth0 : Set default IPv6 router IP and server IP address in this file.

Open /etc/sysconfig/network file, enter:
# vi /etc/sysconfig/network
Append following line:

NETWORKING_IPV6=yes

Open /etc/sysconfig/network-scripts/ifcfg-eth0 (1st network config file)
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Append following config directives for IPv6:

IPV6INIT=yes
IPV6ADDR=<IPv6-IP-Address>
IPV6_DEFAULTGW=<IPv6-IP-Gateway-Address>

Here is my sample file with mix of IPv4 and IPv6 assigned to eth0:

DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:30:48:33:bc:33
IPADDR=202.54.1.5
GATEWAY=202.54.1.3
NETMASK=255.255.255.248
IPV6INIT=yes
IPV6ADDR=2607:f0d0:1002:0011:0000:0000:0000:0002
IPV6_DEFAULTGW=2607:f0d0:1002:0011:0000:0000:0000:0001

Where,

  • NETWORKING_IPV6=yes|no - Enable or disable global IPv6 initialization.
  • IPV6INIT=yes - Enable or disable IPv6 configuration for all interfaces.
  • IPV6ADDR=2607:f0d0:1002:0011:0000:0000:0000:0002 - Specify a primary static IPv6 address here.
  • IPV6_DEFAULTGW=2607:f0d0:1002:0011:0000:0000:0000:0001 - Add a default route through specified gateway.

Save and close the file. Restart networking:
# service network restart
Verify your configuration by pinging ipv6 enabled site such as ipv6.google.com:
$ ping6 ipv6.google.com
Sample output:

PING ipv6.google.com(2001:4860:b002::68) 56 data bytes
64 bytes from 2001:4860:b002::68: icmp_seq=1 ttl=59 time=93.2 ms
64 bytes from 2001:4860:b002::68: icmp_seq=2 ttl=59 time=95.0 ms
64 bytes from 2001:4860:b002::68: icmp_seq=3 ttl=59 time=94.2 ms
64 bytes from 2001:4860:b002::68: icmp_seq=4 ttl=59 time=95.2 ms
64 bytes from 2001:4860:b002::68: icmp_seq=5 ttl=59 time=94.8 ms
64 bytes from 2001:4860:b002::68: icmp_seq=6 ttl=59 time=95.1 ms
64 bytes from 2001:4860:b002::68: icmp_seq=7 ttl=59 time=93.3 ms
64 bytes from 2001:4860:b002::68: icmp_seq=8 ttl=59 time=93.8 ms
--- ipv6.google.com ping statistics ---
8 packets transmitted, 8 received, 0% packet loss, time 7010ms
rtt min/avg/max/mdev = 93.268/94.376/95.268/0.799 ms

Traces path to a network host, enter:
$ traceroute6 ipv6.google.com
Print default IPv6 routing table, enter:
$ route -n -A inet6
Sample output:

Kernel IPv6 routing table
Destination                                 Next Hop                                Flags Metric Ref    Use Iface
::1/128                                     ::                                      U     0      42531       1 lo
::62.41.14.144/128                          ::                                      U     0      0        1 lo
::127.0.0.1/128                             ::                                      U     0      0        1 lo
::/96                                       ::                                      U     256    0        0 sit0
2001:470:1f04:55a::2/128                    ::                                      U     0      15201       1 lo
2001:470:1f04:55a::/64                      ::                                      U     256    0        0 sit1
fe80::4833:22f4/128                         ::                                      U     0      0        1 lo
fe80::212:3fff:fe75:fa0d/128                ::                                      U     0      0        1 lo
fe80::/64                                   ::                                      U     256    0        0 eth0
fe80::/64                                   ::                                      U     256    0        0 sit1
ff00::/8                                    ::                                      U     256    0        0 eth0
ff00::/8                                    ::                                      U     256    0        0 sit1
::/0                                        ::                                      U     1      0        0 sit1

Once IPv6 configured properly, you need to setup IPv6 firewall using ip6tables command under Linux.

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 22 comments… read them below or add one }

1 Sean June 15, 2010 at 6:41 pm

you have no ipv6 mask :(

Reply

2 Beau July 13, 2010 at 7:26 pm

Thanks so much for this article. It is exactly what I have been looking for. I will recommend this article. Keep up the good work.

Reply

3 Pete July 15, 2010 at 4:02 pm

Nice reminders, but I’d like to make two suggestions:

1. Since the gateways are not specific to an interface, I keep the default gateway stuff (v4 and v6) in /etc/sysconfig/network.

2. I also don’t like the v6 autoconf for servers, so I turn it off in /etc/sysconfig/network: IPV6_AUTOCONF=no

Thanks for the quick tips.

Pete

Reply

4 Steve September 27, 2010 at 10:41 am

So how would one find out there IPV6 address to use as a static one and what the default gw IPV6 address us to use?

I know the IPV4 addresses > how do i find its IPV6?

Thanks in advance

Reply

5 SH October 7, 2010 at 11:27 am

I try to add another interface (ifcfg-eth0:1) with the same IPv6 lines as in ifcfg-eth0, but the IPv6 does not appear when I use ifconfig. How can I assign an IPv6 to another network interface?

Reply

6 Pete October 7, 2010 at 6:11 pm

Use IPV6ADDR_SECONDARIES in ifcfg-eth0. Generally, v6 devices expect to have multiple addresses. If you do an ifconfig on eth0, you’ll probably see at least two v6 addresses already (one a link-local scope and one a global scope).

IPV6ADDR_SECONDARIES=”[/] …” (optional)
A list of secondary IPv6 addresses (e.g. useful for virtual hosting)
Example:
IPV6ADDR_SECONDARIES=”3ffe:ffff:0:1::10 3ffe:ffff:0:2::11/128″

Reply

7 S!FE October 20, 2010 at 1:22 pm

Is there any directive to make network service start at boot time.

Reply

8 nixCraft October 20, 2010 at 3:03 pm

Try

 chkconfig network on

Reply

9 S!FE October 20, 2010 at 7:35 pm

I think that works for me, thanks Mr Vivek.

Reply

10 tomas November 16, 2010 at 8:11 pm

Just a question. How can I calculate usable hosts address? I have assigned IPv6 /48 network and need single adress for each server, for example
3x IPv6 address for server-1
2x IPv6 address for server-2
etc …

Reply

11 Louis Kowolowski January 12, 2012 at 5:19 pm

Check out a tool called sipcalc. It supports IPv4 and IPv6 and tells you all the relevant information about a netblock.

http://www.routemeister.net/projects/sipcalc/

Reply

12 Steve August 23, 2012 at 7:02 pm

Thanks Louis

Reply

13 Joel Snyder February 27, 2011 at 11:16 pm

ipv6.google.com doesn’t resolve today, so it’s a bad example. Try http://www.v6.facebook.com.

Reply

14 Monster June 10, 2011 at 12:12 am

any idea how to configure IPv6 in bridge for RH based OS?

Reply

15 Iain Kay July 22, 2011 at 9:26 am

I have a question. If one has setup a CentOS server, and it is now in production sitting online in use 24/7 with IPv4, is it possible to add IPv6 to it without having to restart the network service?

What I have tried:
$ modprobe ipv6
$ ifconfig eth0 && ifconfig xenbr0

By this point there are no ipv6 addresses shown in ifconfig

$ ip addr add 2001:xx:xx:xx:1::2/64 dev xenbr0

By this point I still have no ipv6 addresses in ifconfig, all I get is:
RTNETLINK answers: Operation not supported

If I absolutely have to reboot the server then I will find a good point to do so and do it but if it’s even remotely possible to do without then that would be ideal. The server hosts Xen virtual machines using bridged networking configuration and somehow I doubt that restarting the network service would play nice with them and come back automatically at Virtual Machine level.

Reply

16 George October 17, 2011 at 12:35 am

Hi I dont find /etc/sysconfig/network-scripts/ifcfg-eth0, I only have /etc/sysconfig/network-scripts/ifcfg-lo…….what can I do ? Help me please

Reply

17 Calum November 2, 2011 at 11:24 pm

George – how about cp /etc/sysconfig/network-scripts/ifcfg-lo /etc/sysconfig/network-scripts/ifcfg-eth0
?

Reply

18 Freaky October 24, 2012 at 11:40 am

The scripts aren’t really smart. If you have to use a link local address for your gateway, its not going to work because the route command doesn’t specify the interface.

I solved this quite bluntly – no clue on how future proof this is – by using a zone identifier on the gateway address. As in:

IPV6_DEFAULTGW=fe80::1%eth2

Before more people start the discussion, many hosting providers use the link local address as the gateway because of redundancy. In case of failure of one of the routers the link local address is transferred the global addresses these routers have are NOT! And hence, using one the global addresses at these providers means your routing redundancy is gone.

Reply

19 Freaky October 24, 2012 at 12:09 pm

Earlier I commented on default IPv6 route not working with a link local address for the gateway and that it did work by adding the zone identifier (fe80::1%eth2 for example). Whilst this works nicely for me, I just found out it’s not the official way…

Please update your howto with the following ifcfg-ethX option:
IPV6_DEFAULTDEV=

From the docs:
IPV6_DEFAULTDEV= (optional)
Add a default route through specified interface without specifying next hop
Type of interface will be tested whether this is allowed
Examples:
IPV6_DEFAULTDEV=”eth0″ INVALID example!
IPV6_DEFAULTDEV=”ppp0″
IPV6_DEFAULTDEV=”sit1″
Examples for 6to4
IPV6_DEFAULTDEV=”tun6to4″
Add default route through dedicated 6to4 tunnel device “tun6to4″, if configured

As with all link local address it always has to be specified what device to use. Even ping6 has this issue, because all interfaces get an address in the same range (link local that is).

Reply

20 Aznboy4life June 28, 2013 at 6:50 pm

Hi,

I’m getting:
[ipv6_add_route] ‘No route to host’ adding route ‘::/0′ via gateway ’2607:fcd0:ff03::1′ through device ”

When I restart network. Any ideas? I followed everything above!

Reply

21 Prashant July 12, 2013 at 7:27 am

HI,
I need to configuer ipv6 dhcp server with 112 perfix.Can You help me out

Reply

22 Tom October 28, 2013 at 8:01 pm

I prefer to NOT put in a default gateway for IPv6. You should let the routers on the subnet announce themselves. That’s what Router Announcements (part of Neighbor Discovery) are for. They will announce the proper IPv6 address (which should be a link-local fe80 address) as needed. That RA also includes the “prefix”, which is the IPv6 term for the netmask. Since IPv6 doesn’t permit non-contiguous subnet bits, a straight prefix, which will almost always be /64, should appear in the RA.

Reply

Leave a Comment

Tagged as: , , , , , , , , , , , , , , , , , , , ,

Previous Faq:

Next Faq: