To configure static IPv6 address on your servelet running CentOS Linux operating system, please login to your servelet using SSH as root. There are two files that you need to modify:
1. First, please make a backup copy of the files first.
cp /etc/sysconfig/network /etc/sysconfig/network.bak
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.bak
2. Open the /etc/sysconfig/network file using your favourite text editor (nano or vi):
nano /etc/sysconfig/network
or
vi /etc/sysconfig/network
Default configuration would be like this:
===
NETWORKING=yes
HOSTNAME=your.servelet.hostname
===
Add these following lines after the second line:
===
NETWORKING_IPV6=yes
IPV6_AUTOCONF=no
===
So it will become like this:
===
NETWORKING=yes
NETWORKING_IPV6=yes
IPV6_AUTOCONF=no
HOSTNAME=your.servelet.hostname
===
3. Open the /etc/sysconfig/network-scripts/ifcfg-eth0 file using your favourite text editor (nano or vi):
nano /etc/sysconfig/network-scripts/ifcfg-eth0
or
vi /etc/sysconfig/network-scripts/ifcfg-eth0
Below is the default network configuration:
===
DEVICE=eth0
TYPE=Ethernet
UUID=38a1db46-d3b9-4930-ae4b-ddf9fff4755b
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
===
You would need to modify "IPV6INIT=no" to "IPV6INIT=yes". In addition, please add these lines below the IPV6INIT line:
===
IPV6ADDR=2400:c980:0000:0002::xxxx
IPV6_DEFAULTGW=2400:c980:0000:0002::1
===
Note that 2400:c980:0000:0002::xxxx should be the static IPv6 address which we have assigned to your servelet.
The whole file after the changes should be similar to this:
===
DEVICE=eth0
TYPE=Ethernet
UUID=38a1db46-d3b9-4930-ae4b-ddf9fff4755b
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=yes
IPV6ADDR=2400:c980:0000:0002::xxxx
IPV6_DEFAULTGW=2400:c980:0000:0002::1
NAME="System eth0"
===
Save the file.
4. Issue below command to make the changes to take effect:
service network restart
For example:
===
[root@directadmin log]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0:
Determining IP information for eth0... done.
[ OK ]
===
5. You can then verify if the correct IPv6 address has been installed on your servelet by issuing below command:
ifconfig eth0
For example:
===
root@ns2:/etc/network# ifconfig eth0
[root@directadmin log]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 06:15:E2:01:13:C8
inet addr:103.25.x.x Bcast:103.25.203.255 Mask:255.255.255.0
inet6 addr: 2400:c980:0:2::x/64 Scope:Global
inet6 addr: fe80::415:e2ff:fe01:13c8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:17505 errors:0 dropped:0 overruns:0 frame:0
TX packets:1860 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1307497 (1.2 MiB) TX bytes:401577 (392.1 KiB)
===
Note the line:
inet6 addr: 2400:c980:0:2::3/64 Scope:Global
and verify that the correct IPv6 address is being shown.
That's all! :)