To add an IPv6 network alias to a Red Hat or CentOS server, allowing multiple IPv6 addresses to be assigned to the same NIC (Network Interface Card), you can use the ip
command. Here are the steps:
- Determine the name of the network interface to which you want to add the IPv6 address. You can use the
ip addr
command to list all network interfaces:ip addr
This will display a list of all network interfaces on the system. Identify the interface to which you want to add an IPv6 address, and note its name (such as “eth0” or “ens33”). (www.sanjaytaxpro.com)
- Add the IPv6 address to the interface using the
ip addr add
command, specifying the IPv6 address and the interface name:sudo ip addr add <IPv6_ADDRESS>/<PREFIX_LENGTH> dev <INTERFACE_NAME>
For example, to add an IPv6 address of
2001:db8::2
with a prefix length of64
to theeth0
interface, you would run the following command:sudo ip addr add 2001:db8::2/64 dev eth0
- Verify that the IPv6 address has been added to the interface by using the
ip addr show
command:ip addr show <INTERFACE_NAME>
For example, to show the IPv6 addresses associated with the
eth0
interface, you would run the following command:ip addr show eth0
This will display a list of all IP addresses assigned to the interface, including the newly added IPv6 address.
- (Optional) Make the IPv6 address persistent across reboots by adding it to the appropriate network configuration file. For example, to make the IPv6 address persistent on the
eth0
interface, you would add the following line to the/etc/sysconfig/network-scripts/ifcfg-eth0
file:IPADDR2=2001:db8::2
This will cause the IPv6 address to be added to the
eth0
interface automatically at boot time.
That’s it! You can repeat the above steps to add additional IPv6 addresses to the same network interface, by simply changing the IPv6 address and prefix length as appropriate.