Ifcfg Ipv6 Address Assignment

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. /etc/sysconfig/network : Turn on IPv6 networking and disable IPv6 auto-configuration.
  2. /etc/sysconfig/network-scripts/ifcfg-eth0 : Set static IPv6 address and the default gateway.

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! :)

IPv6 static address configuration for linux hosts

How to statically configure IPv6 on linux systems for the UW Campus network.

By default, most linux distributions use autoconfiguration to pick an IPv6 address that is derived based on the host's mac address. For environments where it is desirable to have static host configurations (for example servers, or other machines to be remotely accessible) you will want to disable autoconfiguration and use a static IPv6 address.

For networks that exclusively want static host configuration, the router can be provisioned to disable autoconfiguration for the entire vlan. This is suitable for vlans that only have servers and static clients. It is not necessarily the best option for client environments unless you want to configure each host by hand. Contact Network Services if you want autoconf disabled for your vlan.

One unique feature of the UW-Madison campus network is that the default gateway will always be fe80::1 regardless of what network you are on. If your host has multiple interfaces, you can only use one of them for your default gateway. This is the same as for IPv4. (Technically you can have multiple default gateways listed but at different metrics so only one is used at a time.)

Fedora, Redhat Enterprise Linux, and clones like Centos

  Add lines to these files:
  • /etc/sysconfig/network
    NETWORKING_IPV6=yes IPV6FORWARDING=no IPV6_AUTOCONF=no IPV6_AUTOTUNNEL=no
  • /etc/sysconfig/network-scripts/ifcfg-eth0
    IPV6INIT=yes IPV6ADDR=2607:f388:xxxx:yyyy::zzzz/64 # replace with your static address IPV6_AUTOCONF="no" IPV6_FAILURE_FATAL="yes" IPV6_DEFAULTGW="FE80::1%eth0"

Debian and derivatives like Ubuntu

  Add lines to these files:
  • /etc/sysctl.conf
    net.ipv6.conf.eth0.accept_ra=0
  • /etc/network/interfaces
    iface lo0 inet6 loopback iface eth0 inet6 static address 2607:f388:xxxx:yyyy::zzzz # replace with your static address netmask 64 gateway fe80::1

One thought on “Ifcfg Ipv6 Address Assignment

Leave a Reply

Your email address will not be published. Required fields are marked *