Docker 网络

常用命令

写在最上面,方便使用
2020-12-09 11:37:23 再次总结

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# 查看有哪些网络
docker network ls

# 查看指定网络的详情信息
docker network inspect name

# ping 通容器名【会在a1容器的 /etc/hosts 中添加 `a1容器ip a1容器id a1容器名称` 】
# 但是此时 a1 仍不能 ping a2
docker run --name a2 --link a1 ...

# 创建网络【示例】
docker network create --driver bridge --subnet 172.27.0.0/16 --gateway 172.27.0.1 my_net
* --driver 驱动类型
* --subnet 子网IP
* 172.27.0.0/16 表示可以创建2^16次方个IP,IP格式为 127.27.x.x 其中 x 表示 0~255
* --gateway 网关
* my_net 自定义网络的名称

# 容器指定网络【两种写法一样】
# 在自定义网络下的容器,可以 ping 这个容器的 ip,容器id,容器名称
# 即使`/etc/hosts`中没有添加东西,自定义网络的特点
docker run --net name ...
docker run --network name ...

# 指定网络别名【两种写法一样】
# 在自定义网络下的容器,可以 ping 这个容器的 ip,容器id,容器名称,容器别名
docker run --net network-name --net-alias network-alias-name ...
docker run --network network-name --network-alias network-alias-name ...

# 连接网络【给centos01容器多分配一个在my_net网段下的IP】
# 容器有多个 ip,可使用 docker inspect centos01 | grep "Networks" -A 50 来查看
# 多个网络下都有这个容器,可使用 docker network inspect my_net
docker network connect my_net centos01

# 删除网络
docker network rm name1 [name2] [name3] ...

# 修改 docker0 网卡(在 /etc/docker/daemon.json 中添加 "bip":"ip/掩码")
cat > /etc/docker/daemon.json << 'EOF'
{
"bip": "172.17.0.1/16",
"registry-mirrors": ["https://wzl8hdkx.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload ; systemctl restart docker

1、容器默认网络是 bridge,也就是说 docker run 若不知道 –net 参数,默认是 bridge
2、默认网络 bridge 下的容器,默认情况下,只可以 ping bridge 下容器的ip,但不可以ping 容器名称,容器id
》》》若想 ping 容器名称,容器id,可以在docker run 时指定 –link 参数,例如:docker run --name a2 --link a1 ...,此时的a2就可以ping a1容器的ip,容器名,容器id了。但是a1不可以ping a2。
》》》因为a2容器的/etc/hosts中有a1容器的信息,而a1容器的/etc/hosts中没有a2容器的信息。
3、在自定义网络下的容器可以互相ping容器名称,容器id,容器ip(自定义网络的特点)
4、网络net01下的a1容器,默认不可用ping通net02下的a2容器,若想ping通,可以使用connect连接:docker network connect net02 a1
》》》意思就是把 a1 容器分配一个 net02 网段下的ip,此时 a1 容器就有了两个ip,两个网段的容器它都可以ping通。
》》》反之,a2容器不可用ping net01网络下的容器,若想打通,则同理可以使用docker network connect net01 a2
5、网络别名,例如:docker run --name a1 --network my_net --network-alias a1-alias ...
》》》只要在 my_net 网络下,都可以ping a1-alias,就相同于 ping a1容器

查看本地网卡

ip addr
可以看到
、lo:本地网卡
、eno16777736:Linux网卡
、docker0:docker自带的虚拟网卡

问题引入

启动容器docker run -it --name centos01 -d centos /bin/bash
启动之后,我们可以看到ip addr多了一个网卡
进入容器docker exec -it centos01 bash
在容器内输入ip addr可查看IP信息,可使用exit退出容器,在容器外输入ip addr也可查看IP信息

docker run -it --name centos02 -d centos /bin/bash
同理我们启动centos02,可以看到ip addr又多了一个网卡
在这里插入图片描述

下面给出网络连接图
在这里插入图片描述
可以看到网卡都是成对的,evth-pair技术。

存在的问题?
只能ping通ip,不能ping通他们的容器名称。
因为在同一网段,所以可以ping同ip地址。如果想ping他们的容器,可使用–link或自定义网络
在这里插入图片描述

–link

启动centos03 测试
docker run -it --name centos03 --link centos01 -d centos /bin/bash
在这里插入图片描述

分析原因:是因为把映射关系写入了hosts文件
docker inspect --format='' centos03
在这里插入图片描述

测试,启动04 –link03时,容器04还是ping centos01吗?答:不行。–link谁,只能ping谁。
在这里插入图片描述

自定义网络

注意:客户端和守护程序API都必须至少为 1.21, 才能使用此命令。可使用docker version检查

命令帮助

docker network --help

1
2
3
4
5
6
7
8
Commands:
connect 将容器连接到网络
create 创建一个网络
disconnect 断开容器与网络的连接
inspect 显示一个或多个网络的详细信息
ls 网络列表
prune 删除所有未使用的网络
rm 删除一个或多个网络

在这里插入图片描述

网络列表

docker network ls

1
2
3
4
DRIVER 驱动类型
bridge:桥接(默认)
none:不配置网络
host:和宿主机共享网络

在这里插入图片描述

创建网络

docker network create --driver bridge --subnet 172.27.0.0/16 --gateway 172.27.0.1 my_net

网络详情

docker network inspect my_net

删除网络

1
2
3
4
# 删除单个
docker network rm name
# 删除多个
docker network rm name1,name2,name3 ...

指定网络启动容器

1)、默认–net介绍
下面两种启动是相同的,容器启动默认是–net bridge,这里bridge是网络的名称

1
2
3
4
5
6
7
8
9
10
docker run -it --name centos01 -d centos /bin/bash

docker run -it --name centos01 --net bridge -d centos /bin/bash


例如:
docker run -itd --name hadoop0 \
--hostname hadoop0 --net network_my --ip 192.168.10.30 \
--add-host hadoop1:192.168.10.31 --add-host hadoop2:192.168.10.32 \
-p 50070:50070 -p 8088:8088 hadoop:master

容器启动网络连接,下面两两作用相同

1
2
3
4
--net               将一个容器连接到一个网络
--network 将一个容器连接到一个网络
--net-alias 为容器添加网络范围的别名
--network-alias 为容器添加网络范围的别名

2)、–net指定自定义网络的使用

1
2
docker run -it --name centos01 --net my_net -d centos /bin/bash
docker run -it --name centos02 --net my_net -d centos /bin/bash

在这里插入图片描述
、容器互ping,这时容器名或ip地址都可以ping同,而且不用配置–link,这样以来,使用自定义网络就可以修复容器名互ping的问题。
在这里插入图片描述

连接网络

docker run -it –name centos01 –net my_net -d centos /bin/bash
docker run -it –name centos02 -d centos /bin/bash

此时容器centos01与centos02两个容器是ping不通的,不属于同一个网段。

表示把centos02连接到my_net网络,连通之后,centos01也就有了两个IP(172.17.0.2,172.27.0.3)
docker network connect my_net centos02
在这里插入图片描述

注意:此时centos01还是ping不了172.17.0.2,但可以ping通容器名centos02 或 172.27.0.3
如果想打通172.17.0.2,则可以同理使用docker network connect bridge centos01
在这里插入图片描述

再次学习

2020-12-09 11:22:00

启动 01,默认加入 bridge 网络,分配ip 172.17.0.4

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
------------------------docker run --name centos01 -itd centos
f152873c31cee7bf4bb03e9185965cba4a844f9bd618e85a18636ee09c9e9edf
------------------------docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' centos01
172.17.0.4
------------------------docker inspect centos01 | grep "Networks" -A 20
"Networks": {
"bridge": { #===> 网络名称 bridge
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "7040b270079d6f4087de2d410ca604c0f8c7259e93e1de78be6401c6b7a59f3b",
"EndpointID": "3755651dc17503bee7a11dcf3e4fcc62edec574e9b9ac17b254463b93992458b",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.4",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:04",
"DriverOpts": null
}
}
}
}
]

启动02,也默认加入 bridge 网络,分配ip 172.17.0.5

1
2
3
4
------------------------docker run --name centos02 -itd centos
deb0293857554d9c91f4e8eb74ec0d25333ebf73a2dc176a91b7305b984c6685
------------------------docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' centos02
172.17.0.5

进入 01 容器,去ping 02 的ip 可以通,因为同一个网段。

》》》但不可以ping容器名称

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
------------------------docker exec -it centos01 bash
[root@f152873c31ce /]# ping 172.17.0.5
PING 172.17.0.5 (172.17.0.5) 56(84) bytes of data.
64 bytes from 172.17.0.5: icmp_seq=1 ttl=64 time=0.501 ms
64 bytes from 172.17.0.5: icmp_seq=2 ttl=64 time=0.059 ms
^C
--- 172.17.0.5 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1ms
rtt min/avg/max/mdev = 0.059/0.280/0.501/0.221 ms
[root@f152873c31ce /]#
[root@f152873c31ce /]#
[root@f152873c31ce /]#
[root@f152873c31ce /]# ping centos02
ping: centos02: Name or service not known
[root@f152873c31ce /]#
[root@f152873c31ce /]# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.4 f152873c31ce

创建网络,网络名称 my_net,网关 172.27.0.1,子网 172.27.0.0/16

》》》进入 01 容器 ping不通 03 的ip,因为不在同一个网段。
》》》使用 docker network connect my_net centos01 ,让 01 加入 my_net网段,并分配一个ip。此时01在bridge,my_net 网段都有 ip
》》》再进入 01,可以ping 03 的ip。因为在同一网段。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
------------------------docker network create --driver bridge --subnet 172.27.0.0/16 --gateway 172.27.0.1 my_net
0063b761953fda46c47da40dd3f3f423ab1a1519684fc7ad1996c3da54035acc
------------------------
------------------------docker network ls
NETWORK ID NAME DRIVER SCOPE
7040b270079d bridge bridge local
e169e6839a1b host host local
3bf28a42efa6 kafka_default bridge local
0063b761953f my_net bridge local
3587385e6117 none null local
------------------------docker network ls | grep my_net
0063b761953f my_net bridge local
------------------------
------------------------docker run --name centos03 -itd --net my_net centos
c2931862510b9982879d800fe0ad930c32e9a4e090f82469f1271d353d916120
------------------------
------------------------
------------------------docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' centos03
172.27.0.2
------------------------
------------------------
------------------------docker exec -it centos01 bash
[root@f152873c31ce /]#
[root@f152873c31ce /]# ping 172.27.0.2
PING 172.27.0.2 (172.27.0.2) 56(84) bytes of data.
^C
--- 172.27.0.2 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 1ms

[root@f152873c31ce /]#
[root@f152873c31ce /]#
[root@f152873c31ce /]# exit
exit
------------------------docker network connect my_net centos01
------------------------
------------------------
------------------------
------------------------docker exec -it centos01 bash
[root@f152873c31ce /]#
[root@f152873c31ce /]# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.4 f152873c31ce
172.27.0.3 f152873c31ce
[root@f152873c31ce /]# ping 127.27.0.2
PING 127.27.0.2 (127.27.0.2) 56(84) bytes of data.
64 bytes from 127.27.0.2: icmp_seq=1 ttl=64 time=0.042 ms
64 bytes from 127.27.0.2: icmp_seq=2 ttl=64 time=0.047 ms
^C
--- 127.27.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.042/0.044/0.047/0.007 ms

–link,创建容器 04,默认加入 bridge 网络

》》》使用 –link centos02 –link centos03 报错:04与03 不在同一网段,所以不能 –link
》》》使用 –link centos01 –link centos02 可以,因为 04 与 01,02在同一网段
》》》进入 04 容器,可以ping 01,02 容器名称。但进 01,02容器就不可以ping 04容器名称
》》》是因为 04 在容器的/etc/hosts 中添加了ip 容器名称 容器id 因此,它可以ping。反之没有添加 –link 所以不可以ping

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
------------------------docker run --name centos04 -itd --link centos02 --link centos03 centos
2a4a313e3cacc330adb962cb63f3d02b74ed0ae51e612acf38b7fa498641b547
docker: Error response from daemon: Cannot link to /centos03, as it does not belong to the default network.
------------------------
------------------------
------------------------docker ps -a | grep centos
2a4a313e3cac centos "/bin/bash" 45 seconds ago Created centos04
c2931862510b centos "/bin/bash" 16 minutes ago Up 16minutes centos03
deb029385755 centos "/bin/bash" 20 minutes ago Up 20minutes centos02
f152873c31ce centos "/bin/bash" 24 minutes ago Up 24minutes centos01
------------------------
------------------------
------------------------docker rm -f centos04
centos04
------------------------
------------------------docker run --name centos04 -itd --link centos01 --link centos02 centos
a61f8de3acb91f210d8d4475ed4c08a5072891a3c1ec387b71bf2e6c01aa829a
------------------------
------------------------
------------------------docker exec -it centos04 bash
[root@a61f8de3acb9 /]# ping centos02
PING centos02 (172.17.0.5) 56(84) bytes of data.
64 bytes from centos02 (172.17.0.5): icmp_seq=1 ttl=64 time=0.075 ms
^C
--- centos02 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.075/0.075/0.075/0.000 ms
[root@a61f8de3acb9 /]# ping centos03
^C
[root@a61f8de3acb9 /]#
[root@a61f8de3acb9 /]#
[root@a61f8de3acb9 /]# ping centos01
PING centos01 (172.17.0.4) 56(84) bytes of data.
64 bytes from centos01 (172.17.0.4): icmp_seq=1 ttl=64 time=0.072 ms
64 bytes from centos01 (172.17.0.4): icmp_seq=2 ttl=64 time=0.065 ms
^C
--- centos01 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.065/0.068/0.072/0.009 ms
[root@a61f8de3acb9 /]#
[root@a61f8de3acb9 /]#
[root@a61f8de3acb9 /]#
[root@a61f8de3acb9 /]# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.4 centos01 f152873c31ce
172.17.0.5 centos02 deb029385755
172.17.0.6 a61f8de3acb9
[root@a61f8de3acb9 /]# exit
exit
------------------------
------------------------
------------------------docker exec -it centos01 bash
[root@f152873c31ce /]# ping centos04
ping: centos04: Name or service not known
[root@f152873c31ce /]#
[root@f152873c31ce /]# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.4 f152873c31ce
172.27.0.3 f152873c31ce
[root@f152873c31ce /]#
[root@f152873c31ce /]# exit
exit

–net,启动 05容器,使用 –net 加入 my_net 自定义网络

》》》进入 05容器,可以ping 03 ip,因为在同一个网段。
》》》也可以ping 03 的容器名称,因为都在自定义网络下面,即使 /etc/hosts中没有定义。
》》》因为这个是自定义网络的特点。而默认的bridge则只支持ip,而不支持容器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
------------------------docker run --name centos05 -itd --net my_net centos
e0920788a76395f499cb11c584717e50465a3daf2ff9c5e8281e7ebdf604f358
------------------------
------------------------
------------------------docker exec -it centos05 bash
[root@e0920788a763 /]# ping 127.27.0.2
PING 127.27.0.2 (127.27.0.2) 56(84) bytes of data.
64 bytes from 127.27.0.2: icmp_seq=1 ttl=64 time=0.050 ms
64 bytes from 127.27.0.2: icmp_seq=2 ttl=64 time=0.046 ms
^C
--- 127.27.0.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 2ms
rtt min/avg/max/mdev = 0.046/0.048/0.050/0.002 ms
[root@e0920788a763 /]#
[root@e0920788a763 /]# ping centos03
PING centos03 (172.27.0.2) 56(84) bytes of data.
64 bytes from centos03.my_net (172.27.0.2): icmp_seq=1 ttl=64 time=0.556 ms
64 bytes from centos03.my_net (172.27.0.2): icmp_seq=2 ttl=64 time=0.061 ms
^C
--- centos03 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 2ms
rtt min/avg/max/mdev = 0.061/0.308/0.556/0.248 ms
[root@e0920788a763 /]#
[root@e0920788a763 /]#
[root@e0920788a763 /]# cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.27.0.4 e0920788a763

–net-alias,网络别名,启动容器 06,使用 –net 指定网络,使用 –net-alias 指定一个网络别名

》》》进入 03 容器,可以ping 06容器名称,ip,容器id(因为在同一个自定义网络下),也可以ping 06 的网络别名(因为指定了网络别名)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
------------------------
------------------------docker run --name centos06 --net my_net --net-alias centos06-alias -itd centos
1e4593cf1b3aa804cd43781ab52b412448bedb116d192ca82fa523deae553daa
------------------------
------------------------
------------------------
------------------------docker network inspect my_net
[
{
"Name": "my_net",
"Id": "0063b761953fda46c47da40dd3f3f423ab1a1519684fc7ad1996c3da54035acc",
"Created": "2020-12-08T18:36:42.832620043-08:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": {},
"Config": [
{
"Subnet": "172.27.0.0/16",
"Gateway": "172.27.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"1e4593cf1b3aa804cd43781ab52b412448bedb116d192ca82fa523deae553daa": {
"Name": "centos06",
"EndpointID": "7ab2610cbf81431ae3749ce286627c8c71715cc7598965e3eab27ec062ac394a",
"MacAddress": "02:42:ac:1b:00:05",
"IPv4Address": "172.27.0.5/16",
"IPv6Address": ""
},
"c2931862510b9982879d800fe0ad930c32e9a4e090f82469f1271d353d916120": {
"Name": "centos03",
"EndpointID": "48ce0e04b8c86be7fde81547c99ffde99fb577ef0c00e930f37b3bd2c3d47494",
"MacAddress": "02:42:ac:1b:00:02",
"IPv4Address": "172.27.0.2/16",
"IPv6Address": ""
},
"e0920788a76395f499cb11c584717e50465a3daf2ff9c5e8281e7ebdf604f358": {
"Name": "centos05",
"EndpointID": "75b4654a99e9f5a1980c5af34291f56167a059925cde5d8adf12f94a7f6f3d90",
"MacAddress": "02:42:ac:1b:00:04",
"IPv4Address": "172.27.0.4/16",
"IPv6Address": ""
},
"f152873c31cee7bf4bb03e9185965cba4a844f9bd618e85a18636ee09c9e9edf": {
"Name": "centos01",
"EndpointID": "bbd62aee722340fef6dbb2584b8119da9e9dc55b9b74cb2adc071d71c5fd9a97",
"MacAddress": "02:42:ac:1b:00:03",
"IPv4Address": "172.27.0.3/16",
"IPv6Address": ""
}
},
"Options": {},
"Labels": {}
}
]
------------------------
------------------------
------------------------docker inspect centos06 | grep "Networks" -A 50
"Networks": {
"my_net": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"centos06-alias",
"1e4593cf1b3a"
],
"NetworkID": "0063b761953fda46c47da40dd3f3f423ab1a1519684fc7ad1996c3da54035acc",
"EndpointID": "7ab2610cbf81431ae3749ce286627c8c71715cc7598965e3eab27ec062ac394a",
"Gateway": "172.27.0.1",
"IPAddress": "172.27.0.5",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:1b:00:05",
"DriverOpts": null
}
}
}
}
]
------------------------
------------------------docker exec -it centos03 bash
[root@c2931862510b /]# ping 172.27.0.5
PING 172.27.0.5 (172.27.0.5) 56(84) bytes of data.
64 bytes from 172.27.0.5: icmp_seq=1 ttl=64 time=0.330 ms
64 bytes from 172.27.0.5: icmp_seq=2 ttl=64 time=0.082 ms
^C
--- 172.27.0.5 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 3ms
rtt min/avg/max/mdev = 0.082/0.206/0.330/0.124 ms
[root@c2931862510b /]# ping centos06
PING centos06 (172.27.0.5) 56(84) bytes of data.
64 bytes from centos06.my_net (172.27.0.5): icmp_seq=1 ttl=64 time=0.073 ms
64 bytes from centos06.my_net (172.27.0.5): icmp_seq=2 ttl=64 time=0.060 ms
^C
--- centos06 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 4ms
rtt min/avg/max/mdev = 0.060/0.066/0.073/0.010 ms
[root@c2931862510b /]# ping centos06-alias
PING centos06-alias (172.27.0.5) 56(84) bytes of data.
64 bytes from centos06.my_net (172.27.0.5): icmp_seq=1 ttl=64 time=0.054 ms
64 bytes from centos06.my_net (172.27.0.5): icmp_seq=2 ttl=64 time=0.068 ms
^C
--- centos06-alias ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 4ms
rtt min/avg/max/mdev = 0.054/0.061/0.068/0.007 ms
[root@c2931862510b /]# ping centos06-alias1 #===> 此别名不存在
^C
[root@c2931862510b /]# ping 1e4593cf1b3a
PING 1e4593cf1b3a (172.27.0.5) 56(84) bytes of data.
64 bytes from centos06.my_net (172.27.0.5): icmp_seq=1 ttl=64 time=0.046 ms
64 bytes from centos06.my_net (172.27.0.5): icmp_seq=2 ttl=64 time=0.060 ms
^C
--- 1e4593cf1b3a ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 2ms
rtt min/avg/max/mdev = 0.046/0.053/0.060/0.007 ms
[root@c2931862510b /]#
[root@c2931862510b /]#
[root@c2931862510b /]#
[root@c2931862510b /]#
[root@c2931862510b /]# exit
exit
------------------------