1. 修改配置文件

    vim /etc/sysconfig/network-scripts/ifcfg-eth0

    在ipv4地址基础上,增加ipv6地址的配置信息,具体配置信息如下:

DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.212.94
PREFIX=24
GATEWAY=192.168.212.254
MTU=
DEFROUTE=yes
  
IPV6INIT=yes
IPV6_AUTOCONF=no
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6ADDR=2018::24/64

    该配置文件为Linux设置的ipv6地址2018::24.

2. 重启network服务:

[root@CentOS ~]# service network restart
正在关闭接口 eth0: 设备状态:3 (断开连接)
                                                           [确定]
关闭环回接口:                                               [确定]
弹出环回接口:                                               [确定]
弹出界面 eth0: 活跃连接状态:已激活
活跃连接路径:/org/freedesktop/NetworkManager/ActiveConnection/3
                                                           [确定]

3. 查看Linux系统网卡信息:

[root@ifcos etc]#ifconfig
eth0      Link encap:Ethernet  HWaddr 00:0C:29:55:F6:E1  
          inet addr:192.168.212.94  Bcast:192.168.212.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:fe55:f6e1/64 Scope:Link
          inet6 addr: 2018::24/64 Scope:Global
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:30873 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1791 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:3312232 (3.1 MiB)  TX bytes:1221610 (1.1 MiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:64 errors:0 dropped:0 overruns:0 frame:0
          TX packets:64 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:3200 (3.1 KiB)  TX bytes:3200 (3.1 KiB)

4. 尝试ping其他ipv6主机

    ping主机2018::90

[root@ifcos etc]#ping6 2018::90
PING 2018::90(2018::90) 56 data bytes
64 bytes from 2018::90: icmp_seq=1 ttl=64 time=7.54 ms
64 bytes from 2018::90: icmp_seq=2 ttl=64 time=1.08 ms
64 bytes from 2018::90: icmp_seq=3 ttl=64 time=1.02 ms
64 bytes from 2018::90: icmp_seq=4 ttl=64 time=1.04 ms
64 bytes from 2018::90: icmp_seq=5 ttl=64 time=0.986 ms
^C
--- 2018::90 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4881ms
rtt min/avg/max/mdev = 0.986/2.334/7.541/2.604 ms

可以ping通。 

 

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐