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

last updated in Categories , , , , , ,

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:

echo -n "Adding IPv6 Alias..."
for i in {$START..$END}
  $IFCONFIG $INT_IF inet6 add ${INETP}${i}/${PRE}
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 \

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.


Posted by: Vivek Gite

The author is the creator of nixCraft and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.

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. the for loop is wrong and should rather be

    for i in $(eval echo “{$START..$END}”)

    or use “while”

  3. 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:
    [root@thinkcentos network-scripts]# pwd

    vi ifcfg-eth0


  4. Is IPV6ADDR required if using IPV6ADDR_SECONDARIES, or can all the addresses be configured as secondaries?

    Still, have a question? Get help on our forum!