在Linux 6.2上設定IPv6


1、查詢kernel是否有載入ipv6的模組
  # modprobe -c |grep ipv6
  如果有看到 alias net-pf-10 ipv6,就表示已經載入ipv6的模組

2、編輯/etc/sysconfig/network,加入 NETWORKING_IPV6=yes
 
  NETWORKING_IPV6=yes|no - 啟用或不啟用global IPv6
 
3、編輯/etc/sysconfig/network-scripts/ifcfg-eth0,並加入下列各行:

  IPV6INIT=yes
  IPV6ADDR=
  IPV6_DEFAULTGW=
 
  我的ifcfg-eth0內容如下,同時支援IPv4與IPv6:
    DEVICE=eth0
    BOOTPROTO=static
    ONBOOT=yes
    HWADDR=08:00:27:95:f9:1c
    IPADDR=192.168.56.201
    GATEWAY=192.168.56.1
    NETMASK=255.255.255.0
    IPV6INIT=yes
    IPV6ADDR=fec0::a00:27ff:fe95:f91c/64
    IPV6_DEFAULTGW=fec0::a00:27ff:fe95:1

  IPV6INIT=yes -啟用IPv6
  IPV6ADDR=fec0::a00:27ff:fe95:f91c/64 -IPv6 address
  IPV6_DEFAULTGW=fec0::a00:27ff:fe95:1 -default gateway

4、重新啟動網路

  # service network restart

5、查詢eth0的狀態,應該就可以看見IPv6的IP
  # ifconfig eth0
 
  eth0    Link encap:Ethernet  HWaddr 08:00:27:95:F9:1C
          inet addr:192.168.56.201  Bcast:192.168.56.255  Mask:255.255.255.0
          inet6 addr: fec0::a00:27ff:fe95:f91c/64 Scope:Site  -->IPv6的Site-local IP
          inet6 addr: fe80::a00:27ff:fe95:f91c/64 Scope:Link  -->IPv6的Link-local IP