How to configure interface with ipv6 address in linux
对不起,现在只有英文版的,不知道发在这合适不。
How to Configure interface with
IPv6 Address in Linux
This document is a brief introduction about how to configure interfaces with IPv6 address in Linux. It is desired to give one a guide to easily configure interfaces with ipv6 address on Linux.
Note: the command used in this document have been confirmed in Redhat Fedora 4, Which used kernel 2.6.x. You shouldn't anymore use kernel series 2.2.x, because it's not IPv6−up−to−date anymore. Also the IPv6 support in series 2.4.x is no longer improved according to definitions in latest RFCs. It's recommend to use series 2.6.x now.
Check the IPv6 Module
Using following command to check whether the ipv6 module has been installed in Linux.
# lsmod | grep ipv6
If the output indicate the ipv6 module has been installed in Linux, you can configure interfaces with ipv6 address. And if the ipv6 module has not been installed in Linux, you should using following command to install it:
# modprobe ipv6
If above command can’t install the ipv6 module in Linux, you should compile the kernel. You should refer to other document about how to compile the kernel.
Configure interfaces with IPv6 address
1. Using command ‘ip’
Usage:
# /sbin/ip −6 addr add <ipv6address>/<prefixlength> dev <interface>
Example:
[root@localhost ~]# /sbin/ip -6 addr add 3000::1001 dev eth1
To Check the conifuration, using following command:
[root@localhost ~]# ip -6 addr show dev eth1 | grep inet6
inet6 3000::1001/128 scope global
inet6 fe80::215:c5ff:fe5f:b39b/64 scope link
2. Using command ‘ifconfig’
Usage:
# /sbin/ifconfig <interface> inet6 add <ipv6address>/<prefixlength>
Example:
[root@localhost ~]# /sbin/ifconfig eth1 inet6 add 3000::1002/64
To Check the conifuration, using following command:
[root@localhost ~]# ifconfig eth1 | grep inet6
inet6 addr: 3000::1002/64 Scope:Global
inet6 addr: fe80::212:3fff:fe24:9f29/64 Scope:Link
3. Modifying the interface config file
The ipv6 address configured by using command ‘ip’ and ‘ifconfig’ will be removed after the interface reset or the system restart. If you want to configure the interface with a static ipv6 address, which should exist even after the interface reset or the system restart, you can modify the network config files.
To accomplish the goal, you need modify following network config files:
/etc/sysconfig/network
/etc/sysconfig/network-scripts/ifcfg-ethx # x is a variable can be replaced by a number
Modify the file ‘/etc/sysconfig/network’ and Add following entry into the file:
NETWORKING_IPV6=yes
Modify the file ‘/etc/sysconfig/networking-scripts/ifcfg-ethx’ and Add following entry into the file:
IPV6INIT=yes
IPV6ADDR= <ipv6 address> # you should replace the <ipv6address> a real ipv6address
Then restart the network service:
# Service network restart
Using Ping6 to check the connectivity between interfaces with ipv6 address
Usage:
# ping6 <ipv6-address>
# ping6 –I <int> <link-local ipv6-address
Example:
[root@localhost ~]# ping6 3000::1001
PING 3000::1001(3000::1001) 56 data bytes
64 bytes from 3000::1001: icmp_seq=0 ttl=64 time=0.184 ms
64 bytes from 3000::1001: icmp_seq=1 ttl=64 time=0.254 ms
64 bytes from 3000::1001: icmp_seq=2 ttl=64 time=0.139 ms
64 bytes from 3000::1001: icmp_seq=3 ttl=64 time=0.139 ms
--- 3000::1001 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3000ms
rtt min/avg/max/mdev = 0.139/0.179/0.254/0.047 ms, pipe 2
[root@localhost ~]# ping6 -I eth1 fe80::212:3fff:fe24:9f29
PING fe80::212:3fff:fe24:9f29(fe80::212:3fff:fe24:9f29) from fe80::212:3fff:fe24:9f29 eth1: 56 data bytes
64 bytes from fe80::212:3fff:fe24:9f29: icmp_seq=0 ttl=64 time=0.040 ms
64 bytes from fe80::212:3fff:fe24:9f29: icmp_seq=1 ttl=64 time=0.031 ms
64 bytes from fe80::212:3fff:fe24:9f29: icmp_seq=2 ttl=64 time=0.035 ms
64 bytes from fe80::212:3fff:fe24:9f29: icmp_seq=3 ttl=64 time=0.032 ms
64 bytes from fe80::212:3fff:fe24:9f29: icmp_seq=4 ttl=64 time=0.033 ms
--- fe80::212:3fff:fe24:9f29 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4000ms
rtt min/avg/max/mdev = 0.031/0.034/0.040/0.004 ms, pipe 2
[root@localhost ~]#
Reference : 《Linux IPv6 HOWTO》-- Peter Bieringer