我是靠谱客的博主 开朗未来,最近开发中收集的这篇文章主要介绍linux配置子接口ipv6地址,CentOS7 设置静态IPv6/IPv4地址,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1 环境准备

实验均在Vmware Workstation虚拟机上完成,上网方式选择桥接模式,保证网络支持IPv6,为了操作方便,我们使用root用户登录系统

1.1 Linux系统版本

CentOS Linux release 7.2.1511 (Core)

1

2

[root@localhost ~]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

1.2 系统支持IPv6

1

2

3

4

5

6

7

8

9

10

[root@localhost ~]# ifconfig

eno16777736: flags=4163mtu 1500

inet 49.123.105.124 netmask 255.255.192.0 broadcast 49.123.127.255

inet6 fe80::20c:29ff:fe25:c621 prefixlen 64 scopeid 0x20

inet6 2001:250:4402:2001:20c:29ff:fe25:c621 prefixlen 64 scopeid 0x0

ether 00:0c:29:25:c6:21 txqueuelen 1000 (Ethernet)

RX packets 19255 bytes 2006024 (1.9 MiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 2151 bytes 210339 (205.4 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

如图所示,可以看到系统默认的IPv6地址为2001:250:4402:2001:20c:29ff:fe25:c621

2 修改网络配置文件

根据1.2,我们得知网卡为eno16777736,切换到目录/etc/sysconfig/network-scripts下

1

[root@localhost ~]# cd /etc/sysconfig/network-scripts

编辑文件 ifcfg-eno16777736

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

[root@localhost ~]# vim ifcfg-eno16777736

TYPE=Ethernet

BOOTPROTO=none

DEFROUTE=yes

IPV4_FAILURE_FATAL=no

IPV6INIT=yes

IPV6_AUTOCONF=no

IPV6_DEFROUTE=yes

IPV6_FAILURE_FATAL=no

NAME=eno16777736

UUID=13faf306-5205-4d3a-ac23-4699236dee95

DEVICE=eno16777736

ONBOOT=yes

DNS1=202.197.96.1

IPV6ADDR=2001:250:4402:2001:20c:29ff:fe25:8888/64

IPADDR=49.123.105.124

PREFIX=8

GATEWAY=49.123.64.1

3 重启网络

1

[root@localhost network-scripts]# systemctl restart network

4 测试是否配置成功

4.1 通过ifconfig命令查看设置的IPv6/IPv4地址

1

2

3

4

5

6

7

8

9

10

11

[root@localhost ~]# ifconfig eno16777736

eno16777736: flags=4163mtu 1500

inet 49.123.105.124 netmask 255.0.0.0 broadcast 49.255.255.255

inet6 2001:250:4402:2001:20c:29ff:fe25:8888 prefixlen 64 scopeid 0x0

inet6 fe80::20c:29ff:fe25:c621 prefixlen 64 scopeid 0x20

inet6 2001:250:4402:2001:20c:29ff:fe25:c621 prefixlen 64 scopeid 0x0

ether 00:0c:29:25:c6:21 txqueuelen 1000 (Ethernet)

RX packets 33732 bytes 8234767 (7.8 MiB)

RX errors 0 dropped 0 overruns 0 frame 0

TX packets 6229 bytes 623829 (609.2 KiB)

TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

4.2 使用另外一台机器进行ping连接测试(两台机器均在同一局域网内)

IPv4测试

1

2

3

4

5

6

7

8

9

10

11

[root@localhost ~]# ping 49.123.105.124

PING 49.123.105.124 (49.123.105.124) 56(84) bytes of data.

64 bytes from 49.123.105.124: icmp_seq=1 ttl=64 time=0.075 ms

64 bytes from 49.123.105.124: icmp_seq=2 ttl=64 time=0.074 ms

64 bytes from 49.123.105.124: icmp_seq=3 ttl=64 time=0.092 ms

64 bytes from 49.123.105.124: icmp_seq=4 ttl=64 time=0.066 ms

64 bytes from 49.123.105.124: icmp_seq=5 ttl=64 time=0.067 ms

^C

--- 49.123.105.124 ping statistics ---

5 packets transmitted, 5 received, 0% packet loss, time 4004ms

rtt min/avg/max/mdev = 0.066/0.074/0.092/0.014 ms

IPv6测试

1

2

3

4

5

6

7

8

9

10

[root@localhost ~]# ping6 2001:250:4402:2001:20c:29ff:fe25:8888

PING 2001:250:4402:2001:20c:29ff:fe25:8888(2001:250:4402:2001:20c:29ff:fe25:8888) 56 data bytes

64 bytes from 2001:250:4402:2001:20c:29ff:fe25:8888: icmp_seq=1 ttl=64 time=0.099 ms

64 bytes from 2001:250:4402:2001:20c:29ff:fe25:8888: icmp_seq=2 ttl=64 time=0.110 ms

64 bytes from 2001:250:4402:2001:20c:29ff:fe25:8888: icmp_seq=3 ttl=64 time=0.126 ms

64 bytes from 2001:250:4402:2001:20c:29ff:fe25:8888: icmp_seq=4 ttl=64 time=0.110 ms

64 bytes from 2001:250:4402:2001:20c:29ff:fe25:8888: icmp_seq=5 ttl=64 time=0.113 ms

^C

--- 2001:250:4402:2001:20c:29ff:fe25:8888 ping statistics ---

5 packets transmitted, 5 received, 0% packet loss, time 4003ms

恭喜你,到此已经完成了CentOS 7的静态IPv6/IPV4配置

坚持原创技术分享,您的支持将鼓励我继续创作!

本文作者: lemon

本文链接: https://lemon2013.github.io/2016/11/06/Static-IPv6/

版权声明:本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!

最后

以上就是开朗未来为你收集整理的linux配置子接口ipv6地址,CentOS7 设置静态IPv6/IPv4地址的全部内容,希望文章能够帮你解决linux配置子接口ipv6地址,CentOS7 设置静态IPv6/IPv4地址所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(41)

评论列表共有 0 条评论

立即
投稿
返回
顶部