Red Hat / CentOS Add IPv6 Network Alias (multiple IPv6 IP to Same NIC)

Posted on in Categories , , , , , , last updated January 25, 2009

Q. How do I add multiple IPv6 address to eth0 under Red Hat / Fedora / RHEL / CentOS Linux for virtual hosting?

A. There are two ways to add network aliaes under Red hat / CentOS Linux system. You need to edit any one of the following file in order to add IPv6 network alias.

  1. /etc/rc.local – Use ifconfig command and shell loop.
  2. /etc/sysconfig/network-scripts/ifcfg-eth0 – Set special variable called IPV6ADDR_SECONDARIES for eth0 virtual hosting (network alias).

First, setup IPv6 main server IP address and default router. Once basic IPv6 connectivity established you can setup aliases for NIC.

/etc/rc.local configuration

To add 2607:f0d0:1002:11::10 to 2607:f0d0:1002:11::50 (total 40) virtual aliases, open /etc/rc.local file, enter:
# vi /etc/rc.local
Append following code:

#IP Alias
for ip in {10..40}; do /sbin/ifconfig eth0 inet6 add 2607:f0d0:1002:11::${ip}/64; done

You can type the same command at a shell prompt to immediately activate network aliases. Or create a shell script and call it from /etc/rc.local itself:

#!/bin/bash
INETP="2607:f0d0:1002:11::"
PRE="64"
START=2
END=200
INT_IF="eth0"
IFCONFIG=/sbin/ifconfig
echo -n "Adding IPv6 Alias..."
for i in {$START..$END}
do
  $IFCONFIG $INT_IF inet6 add ${INETP}${i}/${PRE}
done
echo "Done!"

sysv style configuration

Open network interface configuration file, enter:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Append a list of secondary IPv6 addresses following code (set 5 aliases):

IPV6ADDR_SECONDARIES="2607:f0d0:1002:11::10/64 \
2607:f0d0:1002:11::11/64 \
2607:f0d0:1002:11::12/64 \
2607:f0d0:1002:11::13/64 \
2607:f0d0:1002:11::14/64"

Save and close the file. Restart networking:
# /etc/init.d/network restart
Test your connectivity using ping6 and other tools:
$ /sbin/ifconfig
$ /sbin/ifconfig eth0 | less
$ ping6 2607:f0d0:1002:11::15

You may need to setup simple or complicated IPv6 firewall.

7 comment

  1. while adding ipv6 address to network ,is that prefix length is fixed to 64 or it can be vary?can anyone explain this?please….thanks in advance.

  2. Following your sysv style configuration:

    Problem: I don’t have entry starting IPV6ADDR_SECONDARIES=

    or did you mean just append as written? Please advise.

    My system:
    [[email protected] network-scripts]# pwd
    /etc/sysconfig/network-scripts

    vi ifcfg-eth0

    DEVICE=”eth0″
    BOOTPROTO=”dhcp”
    HWADDR=”00:0C:29:29:75:55″
    IPV6INIT=”yes”
    NM_CONTROLLED=”yes”
    ONBOOT=”yes”
    TYPE=”Ethernet”
    UUID=”60f24514-5d98-4251-bd19-1e654f3b9479″

Leave a Comment