zabbix v7.2.3容器运行Proxy代理服务器启用IPV6访问
本文系在openEuler22.03系统上部署zabbix v7.2.3的Proxy代理服务器容器,并启用IPV6功能以便监控IPV6网元的实战化实践。openEuler22.03原生docker包不支持ip6tables自动配置功能,需提前将docker引擎进行升级,详细操作请参见本人前文:
openEuler22.03LTS系统升级docker至26.1.4以支持启用ip6tables功能
升级 docker引擎再进行以下部署操作。
一、现有环境
1、系统版本
# cat /etc/os-release
NAME="openEuler"
VERSION="22.03 LTS"
ID="openEuler"
VERSION_ID="22.03"
PRETTY_NAME="openEuler 22.03 LTS"
ANSI_COLOR="0;31"
2、docker版本
# docker --version
Docker version 26.1.4, build 5650f9b
# docker version
Client:
Version: 26.1.4
API version: 1.45
Go version: go1.21.11
Git commit: 5650f9b
Built: Wed Jun 5 11:27:57 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 26.1.4
API version: 1.45 (minimum version 1.24)
Go version: go1.21.11
Git commit: de5c9cf
Built: Wed Jun 5 11:29:25 2024
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: v1.7.18
GitCommit: ae71819c4f5e67bb4d5ae76a6b735f29cc25774e
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
3、确认当前系统IPV6已启用
# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:ad:24:77 brd ff:ff:ff:ff:ff:ff
altname enp11s0
inet 192.168.17.243/24 brd 192.168.17.255 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet6 2025:0207:5a25:1::ae3:11f3/120 scope global noprefixroute
valid_lft forever preferred_lft forever
inet6 fe80::250:56ff:fead:2477/64 scope link noprefixroute
valid_lft forever preferred_lft forever
主机配置启用了IPV6地址2025:0207:5a25:1::ae3:11f3。
4、测试外部连接
# ping6 2025:0207:5a25:1::ae3:1101
PING 2025:0207:5a25:1::ae3:1101(2025:0207:5a25:1::ae3:1101) 56 data bytes
64 bytes from 2025:0207:5a25:1::ae3:1101: icmp_seq=1 ttl=64 time=0.435 ms
64 bytes from 2025:0207:5a25:1::ae3:1101: icmp_seq=2 ttl=64 time=0.468 ms
64 bytes from 2025:0207:5a25:1::ae3:1101: icmp_seq=3 ttl=64 time=0.445 ms
^C
--- 2025:0207:5a25:1::ae3:1101 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2073ms
rtt min/avg/max/mdev = 0.435/0.449/0.468/0.013 ms
二、系统及docker引擎配置启用ipv6转发
1、开启主机的 IPv6 转发功能
编辑/etc/sysctl.conf文件,确保以下2项存在并且值为1,为主机开启了 IPv6 转发功能,这样主机才能将容器的 IPv6 流量转发到外部网络。
# vi /etc/sysctl.conf
...
net.ipv6.conf.all.accept_redirects=1
net.ipv6.conf.default.accept_redirects=1
...
2、开启docker引擎的IPV6支持
编辑 /etc/docker/daemon.json
文件,添加或修改以下内容:
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64",
"experimental":true,
"ip6tables": true
}
重启容器引擎
三、运行zabbix v7.2.3系统Proxy代理服务器容器
1、启用自定义网络
编写脚本如下
# vi 0-zbxbridgenetmk.sh
#!/bin/bash
##__author__='daigjianbing'
if grep -q "DISABLE_CRASH_FILES_DELETE=true" /etc/sysconfig/docker ; then echo "配置ok无需修改" ; else echo "DISABLE_CRASH_FILES_DELETE=true" >> /etc/sysconfig/docker && echo "配置已修改"; fi
zabbixnet=`docker network list|grep -w 'zabbixnet'|wc -l`
if [ $zabbixnet -eq 0 ];then echo "添加自定义网络zabbixnet" && docker network create --subnet=172.18.0.0/24 --ipv6 --subnet=2001:db8:18::/64 --gateway=2001:db8:18::1 zabbixnet;fi
docker network list
定义zabbixnet 网络,容器运行的IPV4地址段172.18.0.0/24,容器引擎IPV4网关默认地址172.18.0.1无需配置,IPV6地址段2001:db8:18::/64,配置容器引擎IPV6网关地址2001:db8:18::1,执行指令
# sh 0-zbxbridgenetmk.sh
grep: /etc/sysconfig/docker: No such file or directory
配置已修改
添加自定义网络zabbixnet
5cb49bcf29a262d701cb6b67d98b0066c5397607e614a9d65a7f8c2886192d7a
NETWORK ID NAME DRIVER SCOPE
cf8e3d0371b5 bridge bridge local
e6ab498a1ced host host local
ad907e30b885 none null local
5cb49bcf29a2 zabbixnet bridge local
可以看到自定义网络zabbixnet已生成。
2、生成mariadb数据库容器
编写脚本如下:
# vi 1-mysqldbrun.sh
#!/bin/bash
##__author__='daigjianbing'
docker run -itd --restart=always --name mysqldb --net zabbixnet --ip 172.18.0.2 -v /data/mysqldata:/var/lib/mysql -v /data/mysqlcnf/mariadb.cnf:/etc/mysql/mariadb.cnf -p 3306:3306 mariadb:10.5.18
mariadb数据库容器为IPV4内部运行,固定地址为172.18.0.2,前期已完成数据持久化配置,直接运行即可
# sh 1-mysqldbrun.sh
7f2ad4cc602a2bc8ecfdbe1facd1753d23836a2c279c8b3399f7010b1c8639e1
3、运行zabbix代理服务器容器
编写脚本如下:
# vi 2-mkproxy.sh
#!/bin/bash
##__author__='daigjianbing'
docker rm -f zbxpro
docker run -itd --restart=always --name zbxpro --net zabbixnet --ip 172.18.0.3 --ip6 2001:db8:18::10 --env-file /data/zabbixcnf/zabbix_proxy.env -v /etc/localtime:/etc/localtime -p 10051:10051 zabbix/zabbix-proxy-mysql:centos-7.2.3
固定代理服务器IPV4地址172.18.0.3,IPV6地址2001:db8:18::10,执行脚本启动容器
# sh 2-mkproxy.sh
Error response from daemon: No such container: zbxpro
3ee9719a25c450bdb8a79d06b7229ac35db7c4ede74ed656528adfdc8e7ca7bf
检查容器日志
# docker logs -f zbxpro
** Preparing Zabbix proxy
** Preparing database
** Using MYSQL_USER variable from ENV
** Using MYSQL_PASSWORD variable from ENV
********************
* DB_SERVER_HOST: 172.18.0.2
* DB_SERVER_PORT: 3306
* DB_SERVER_DBNAME: zabbix_proxy
********************
** Database 'zabbix_proxy' already exists. Please be careful with database COLLATE!
** Table 'zabbix_proxy.dbversion' already exists.
Starting Zabbix Proxy (active) [ZBXPRO224_192.168.17.224]. Zabbix 7.2.3 (revision ff99a1b).
Press Ctrl+C to exit.
1:20250207:153306.504 Starting Zabbix Proxy (active) [ZBXPRO224_192.168.17.224]. Zabbix 7.2.3 (revision ff99a1b).
1:20250207:153306.504 **** Enabled features ****
1:20250207:153306.504 SNMP monitoring: YES
1:20250207:153306.504 IPMI monitoring: YES
1:20250207:153306.504 Web monitoring: YES
1:20250207:153306.504 VMware monitoring: YES
1:20250207:153306.504 ODBC: YES
1:20250207:153306.504 SSH support: YES
1:20250207:153306.504 IPv6 support: YES
1:20250207:153306.504 TLS support: YES
1:20250207:153306.504 **************************
1:20250207:153306.504 using configuration file: /etc/zabbix/zabbix_proxy.conf
1:20250207:153306.584 current database version (mandatory/optional): 07020000/07020000
1:20250207:153306.584 required mandatory version: 07020000
1:20250207:153306.588 proxy #0 started [main process]
24:20250207:153306.589 proxy #1 started [configuration syncer #1]
25:20250207:153309.674 proxy #2 started [trapper #1]
26:20250207:153309.675 proxy #3 started [trapper #2]
27:20250207:153309.675 proxy #4 started [trapper #3]
32:20250207:153309.677 proxy #9 started [housekeeper #1]
33:20250207:153309.677 proxy #10 started [http poller #1]
24:20250207:153309.677 cannot obtain configuration data from server at "192.168.17.253": empty string received
31:20250207:153309.678 proxy #8 started [data sender #1]
34:20250207:153309.678 proxy #11 started [browser poller #1]
37:20250207:153309.678 proxy #14 started [history syncer #2]
38:20250207:153309.679 proxy #15 started [history syncer #3]
40:20250207:153309.679 proxy #17 started [history syncer #5]
42:20250207:153309.680 proxy #19 started [history syncer #7]
35:20250207:153309.680 proxy #12 started [discovery manager #1]
43:20250207:153309.680 proxy #20 started [history syncer #8]
39:20250207:153309.680 proxy #16 started [history syncer #4]
45:20250207:153309.681 proxy #22 started [task manager #1]
44:20250207:153309.681 proxy #21 started [self-monitoring #1]
41:20250207:153309.681 proxy #18 started [history syncer #6]
47:20250207:153309.681 proxy #24 started [poller #2]
36:20250207:153309.682 proxy #13 started [history syncer #1]
29:20250207:153309.683 proxy #6 started [trapper #5]
48:20250207:153309.683 proxy #25 started [poller #3]
49:20250207:153309.684 proxy #26 started [poller #4]
28:20250207:153309.686 proxy #5 started [trapper #4]
51:20250207:153309.686 proxy #28 started [poller #6]
50:20250207:153309.686 proxy #27 started [poller #5]
46:20250207:153309.688 proxy #23 started [poller #1]
52:20250207:153309.688 proxy #29 started [poller #7]
30:20250207:153309.689 proxy #7 started [preprocessing manager #1]
53:20250207:153309.691 proxy #30 started [poller #8]
54:20250207:153309.692 proxy #31 started [poller #9]
56:20250207:153309.694 proxy #33 started [poller #11]
57:20250207:153309.695 proxy #34 started [poller #12]
58:20250207:153309.695 proxy #35 started [poller #13]
64:20250207:153309.696 proxy #41 started [poller #19]
60:20250207:153309.697 proxy #37 started [poller #15]
59:20250207:153309.698 proxy #36 started [poller #14]
55:20250207:153309.698 proxy #32 started [poller #10]
66:20250207:153309.699 proxy #43 started [poller #21]
62:20250207:153309.699 proxy #39 started [poller #17]
61:20250207:153309.700 proxy #38 started [poller #16]
63:20250207:153309.702 proxy #40 started [poller #18]
105:20250207:153309.707 proxy #82 started [poller #60]
65:20250207:153309.707 proxy #42 started [poller #20]
107:20250207:153309.709 proxy #84 started [poller #62]
113:20250207:153309.710 proxy #90 started [unreachable poller #4]
67:20250207:153309.711 proxy #44 started [poller #22]
117:20250207:153309.712 proxy #94 started [unreachable poller #8]
68:20250207:153309.713 proxy #45 started [poller #23]
69:20250207:153309.714 proxy #46 started [poller #24]
70:20250207:153309.715 proxy #47 started [poller #25]
71:20250207:153309.716 proxy #48 started [poller #26]
72:20250207:153309.717 proxy #49 started [poller #27]
73:20250207:153309.718 proxy #50 started [poller #28]
74:20250207:153309.719 proxy #51 started [poller #29]
75:20250207:153309.720 proxy #52 started [poller #30]
76:20250207:153309.720 proxy #53 started [poller #31]
77:20250207:153309.721 proxy #54 started [poller #32]
78:20250207:153309.722 proxy #55 started [poller #33]
79:20250207:153309.722 proxy #56 started [poller #34]
81:20250207:153309.723 proxy #58 started [poller #36]
30:20250207:153309.723 [3] thread started [preprocessing worker #3]
106:20250207:153309.723 proxy #83 started [poller #61]
108:20250207:153309.724 proxy #85 started [poller #63]
103:20250207:153309.724 proxy #80 started [poller #58]
80:20250207:153309.726 proxy #57 started [poller #35]
102:20250207:153309.726 proxy #79 started [poller #57]
109:20250207:153309.726 proxy #86 started [poller #64]
101:20250207:153309.728 proxy #78 started [poller #56]
110:20250207:153309.728 proxy #87 started [unreachable poller #1]
111:20250207:153309.729 proxy #88 started [unreachable poller #2]
112:20250207:153309.731 proxy #89 started [unreachable poller #3]
114:20250207:153309.731 proxy #91 started [unreachable poller #5]
100:20250207:153309.731 proxy #77 started [poller #55]
115:20250207:153309.733 proxy #92 started [unreachable poller #6]
99:20250207:153309.733 proxy #76 started [poller #54]
116:20250207:153309.734 proxy #93 started [unreachable poller #7]
104:20250207:153309.735 proxy #81 started [poller #59]
118:20250207:153309.736 proxy #95 started [unreachable poller #9]
119:20250207:153309.737 proxy #96 started [unreachable poller #10]
82:20250207:153309.737 proxy #59 started [poller #37]
120:20250207:153309.738 proxy #97 started [unreachable poller #11]
30:20250207:153309.739 [1] thread started [preprocessing worker #1]
30:20250207:153309.739 [2] thread started [preprocessing worker #2]
30:20250207:153309.739 [4] thread started [preprocessing worker #4]
83:20250207:153309.739 proxy #60 started [poller #38]
30:20250207:153309.739 [5] thread started [preprocessing worker #5]
30:20250207:153309.740 [6] thread started [preprocessing worker #6]
30:20250207:153309.740 [7] thread started [preprocessing worker #7]
30:20250207:153309.740 [8] thread started [preprocessing worker #8]
30:20250207:153309.740 [9] thread started [preprocessing worker #9]
30:20250207:153309.740 [10] thread started [preprocessing worker #10]
30:20250207:153309.740 [11] thread started [preprocessing worker #11]
30:20250207:153309.740 [12] thread started [preprocessing worker #12]
30:20250207:153309.741 [13] thread started [preprocessing worker #13]
30:20250207:153309.741 [14] thread started [preprocessing worker #14]
30:20250207:153309.741 [15] thread started [preprocessing worker #15]
30:20250207:153309.741 [16] thread started [preprocessing worker #16]
84:20250207:153309.741 proxy #61 started [poller #39]
85:20250207:153309.741 proxy #62 started [poller #40]
86:20250207:153309.743 proxy #63 started [poller #41]
87:20250207:153309.744 proxy #64 started [poller #42]
88:20250207:153309.745 proxy #65 started [poller #43]
89:20250207:153309.746 proxy #66 started [poller #44]
90:20250207:153309.748 proxy #67 started [poller #45]
137:20250207:153309.749 proxy #98 started [unreachable poller #12]
91:20250207:153309.750 proxy #68 started [poller #46]
144:20250207:153309.751 proxy #105 started [icmp pinger #3]
146:20250207:153309.752 proxy #107 started [icmp pinger #5]
148:20250207:153309.753 proxy #109 started [icmp pinger #7]
93:20250207:153309.753 proxy #70 started [poller #48]
150:20250207:153309.754 proxy #111 started [icmp pinger #9]
151:20250207:153309.754 proxy #112 started [icmp pinger #10]
153:20250207:153309.755 proxy #114 started [odbc poller #1]
92:20250207:153309.755 proxy #69 started [poller #47]
98:20250207:153309.755 proxy #75 started [poller #53]
143:20250207:153309.757 proxy #104 started [icmp pinger #2]
145:20250207:153309.757 proxy #106 started [icmp pinger #4]
97:20250207:153309.758 proxy #74 started [poller #52]
147:20250207:153309.758 proxy #108 started [icmp pinger #6]
149:20250207:153309.758 proxy #110 started [icmp pinger #8]
152:20250207:153309.758 proxy #113 started [availability manager #1]
154:20250207:153309.759 proxy #115 started [http agent poller #1]
35:20250207:153309.759 thread started [discovery worker #1]
35:20250207:153309.759 thread started [discovery worker #2]
35:20250207:153309.759 thread started [discovery worker #3]
35:20250207:153309.759 thread started [discovery worker #4]
35:20250207:153309.759 thread started [discovery worker #5]
160:20250207:153309.759 proxy #116 started [agent poller #1]
96:20250207:153309.759 proxy #73 started [poller #51]
95:20250207:153309.760 proxy #72 started [poller #50]
161:20250207:153309.760 proxy #117 started [snmp poller #1]
162:20250207:153309.761 proxy #118 started [internal poller #1]
139:20250207:153309.761 proxy #100 started [unreachable poller #14]
141:20250207:153309.762 proxy #102 started [unreachable poller #16]
154:20250207:153309.762 thread started
94:20250207:153309.762 proxy #71 started [poller #49]
138:20250207:153309.763 proxy #99 started [unreachable poller #13]
140:20250207:153309.764 proxy #101 started [unreachable poller #15]
142:20250207:153309.764 proxy #103 started [icmp pinger #1]
160:20250207:153309.764 thread started
161:20250207:153309.764 thread started
31:20250207:153309.847 cannot send proxy data to server at "192.168.17.253": connection is not allowed
47:20250207:153310.685 forced reloading of the snmp cache on [poller #2]
49:20250207:153310.686 forced reloading of the snmp cache on [poller #4]
48:20250207:153310.686 forced reloading of the snmp cache on [poller #3]
50:20250207:153310.688 forced reloading of the snmp cache on [poller #5]
51:20250207:153310.689 forced reloading of the snmp cache on [poller #6]
46:20250207:153310.690 forced reloading of the snmp cache on [poller #1]
52:20250207:153310.693 forced reloading of the snmp cache on [poller #7]
53:20250207:153310.695 forced reloading of the snmp cache on [poller #8]
54:20250207:153310.695 forced reloading of the snmp cache on [poller #9]
56:20250207:153310.697 forced reloading of the snmp cache on [poller #11]
57:20250207:153310.698 forced reloading of the snmp cache on [poller #12]
64:20250207:153310.699 forced reloading of the snmp cache on [poller #19]
60:20250207:153310.700 forced reloading of the snmp cache on [poller #15]
66:20250207:153310.701 forced reloading of the snmp cache on [poller #21]
55:20250207:153310.702 forced reloading of the snmp cache on [poller #10]
58:20250207:153310.702 forced reloading of the snmp cache on [poller #13]
61:20250207:153310.702 forced reloading of the snmp cache on [poller #16]
62:20250207:153310.702 forced reloading of the snmp cache on [poller #17]
63:20250207:153310.705 forced reloading of the snmp cache on [poller #18]
59:20250207:153310.706 forced reloading of the snmp cache on [poller #14]
105:20250207:153310.710 forced reloading of the snmp cache on [poller #60]
65:20250207:153310.710 forced reloading of the snmp cache on [poller #20]
107:20250207:153310.711 forced reloading of the snmp cache on [poller #62]
67:20250207:153310.714 forced reloading of the snmp cache on [poller #22]
68:20250207:153310.716 forced reloading of the snmp cache on [poller #23]
69:20250207:153310.717 forced reloading of the snmp cache on [poller #24]
70:20250207:153310.718 forced reloading of the snmp cache on [poller #25]
71:20250207:153310.719 forced reloading of the snmp cache on [poller #26]
73:20250207:153310.720 forced reloading of the snmp cache on [poller #28]
72:20250207:153310.720 forced reloading of the snmp cache on [poller #27]
74:20250207:153310.721 forced reloading of the snmp cache on [poller #29]
76:20250207:153310.722 forced reloading of the snmp cache on [poller #31]
75:20250207:153310.722 forced reloading of the snmp cache on [poller #30]
77:20250207:153310.723 forced reloading of the snmp cache on [poller #32]
79:20250207:153310.724 forced reloading of the snmp cache on [poller #34]
78:20250207:153310.724 forced reloading of the snmp cache on [poller #33]
81:20250207:153310.725 forced reloading of the snmp cache on [poller #36]
106:20250207:153310.726 forced reloading of the snmp cache on [poller #61]
108:20250207:153310.726 forced reloading of the snmp cache on [poller #63]
103:20250207:153310.727 forced reloading of the snmp cache on [poller #58]
102:20250207:153310.728 forced reloading of the snmp cache on [poller #57]
80:20250207:153310.729 forced reloading of the snmp cache on [poller #35]
109:20250207:153310.729 forced reloading of the snmp cache on [poller #64]
101:20250207:153310.730 forced reloading of the snmp cache on [poller #56]
83:20250207:153310.742 forced reloading of the snmp cache on [poller #38]
85:20250207:153310.744 forced reloading of the snmp cache on [poller #40]
84:20250207:153310.744 forced reloading of the snmp cache on [poller #39]
86:20250207:153310.746 forced reloading of the snmp cache on [poller #41]
99:20250207:153310.748 forced reloading of the snmp cache on [poller #54]
100:20250207:153310.748 forced reloading of the snmp cache on [poller #55]
88:20250207:153310.748 forced reloading of the snmp cache on [poller #43]
104:20250207:153310.748 forced reloading of the snmp cache on [poller #59]
89:20250207:153310.749 forced reloading of the snmp cache on [poller #44]
82:20250207:153310.750 forced reloading of the snmp cache on [poller #37]
90:20250207:153310.761 forced reloading of the snmp cache on [poller #45]
95:20250207:153310.762 forced reloading of the snmp cache on [poller #50]
96:20250207:153310.762 forced reloading of the snmp cache on [poller #51]
91:20250207:153310.764 forced reloading of the snmp cache on [poller #46]
93:20250207:153310.764 forced reloading of the snmp cache on [poller #48]
87:20250207:153310.764 forced reloading of the snmp cache on [poller #42]
92:20250207:153310.764 forced reloading of the snmp cache on [poller #47]
94:20250207:153310.765 forced reloading of the snmp cache on [poller #49]
98:20250207:153310.765 forced reloading of the snmp cache on [poller #53]
97:20250207:153310.766 forced reloading of the snmp cache on [poller #52]
31:20250207:153310.848 cannot send proxy data to server at "192.168.17.253": connection is not allowed
31:20250207:153311.849 cannot send proxy data to server at "192.168.17.253": connection is not allowed
31:20250207:153312.850 cannot send proxy data to server at "192.168.17.253": connection is not allowed
31:20250207:153313.851 cannot send proxy data to server at "192.168.17.253": connection is not allowed
117:20250207:153314.715 forced reloading of the snmp cache on [unreachable poller #8]
113:20250207:153314.715 forced reloading of the snmp cache on [unreachable poller #4]
110:20250207:153314.735 forced reloading of the snmp cache on [unreachable poller #1]
111:20250207:153314.735 forced reloading of the snmp cache on [unreachable poller #2]
120:20250207:153314.742 forced reloading of the snmp cache on [unreachable poller #11]
112:20250207:153314.744 forced reloading of the snmp cache on [unreachable poller #3]
114:20250207:153314.756 forced reloading of the snmp cache on [unreachable poller #5]
118:20250207:153314.759 forced reloading of the snmp cache on [unreachable poller #9]
115:20250207:153314.760 forced reloading of the snmp cache on [unreachable poller #6]
137:20250207:153314.765 forced reloading of the snmp cache on [unreachable poller #12]
119:20250207:153314.768 forced reloading of the snmp cache on [unreachable poller #10]
116:20250207:153314.770 forced reloading of the snmp cache on [unreachable poller #7]
140:20250207:153314.772 forced reloading of the snmp cache on [unreachable poller #15]
139:20250207:153314.777 forced reloading of the snmp cache on [unreachable poller #14]
141:20250207:153314.782 forced reloading of the snmp cache on [unreachable poller #16]
可以看到容器运行正常。
四、测试从容器内访问外部IPV6网络
1、准备ping6命令
zabbix原生proxy容器中没有打包ping命令,需要手工传入
# which ping6
/usr/sbin/ping6
# ll /usr/sbin/ping6
lrwxrwxrwx. 1 root root 11 Mar 10 2022 /usr/sbin/ping6 -> ../bin/ping
# ll /usr/bin/ping
-rwxr-xr-x. 1 root root 75K Mar 10 2022 /usr/bin/ping
# docker cp /usr/bin/ping zbxpro:/usr/sbin/ping6
Successfully copied 79.4kB to zbxpro:/usr/sbin/ping6
2、登入容器测试到外部IPV6网络连接
2.1 测试到主机网卡地址
# docker exec -it zbxpro /bin/bash
bash-5.1$ ping6 2025:0207:5a25:1::ae3:11f3
PING 2025:0207:5a25:1::ae3:11f3(2025:0207:5a25:1::ae3:11f3) 56 data bytes
64 bytes from 2025:0207:5a25:1::ae3:11f3: icmp_seq=1 ttl=64 time=0.036 ms
64 bytes from 2025:0207:5a25:1::ae3:11f3: icmp_seq=2 ttl=64 time=0.036 ms
64 bytes from 2025:0207:5a25:1::ae3:11f3: icmp_seq=3 ttl=64 time=0.038 ms
64 bytes from 2025:0207:5a25:1::ae3:11f3: icmp_seq=4 ttl=64 time=0.035 ms
64 bytes from 2025:0207:5a25:1::ae3:11f3: icmp_seq=5 ttl=64 time=0.039 ms
^C
--- 2025:0207:5a25:1::ae3:11f3 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4091ms
rtt min/avg/max/mdev = 0.035/0.036/0.039/0.001 ms
访问主机正常。
2.2 测试到主机网关地址
bash-5.1$ ping6 2025:0207:5a25:1::ae3:1101
PING 2025:0207:5a25:1::ae3:1101(2025:0207:5a25:1::ae3:1101) 56 data bytes
64 bytes from 2025:0207:5a25:1::ae3:1101: icmp_seq=1 ttl=63 time=0.473 ms
64 bytes from 2025:0207:5a25:1::ae3:1101: icmp_seq=2 ttl=63 time=0.425 ms
64 bytes from 2025:0207:5a25:1::ae3:1101: icmp_seq=3 ttl=63 time=0.523 ms
^C
--- 2025:0207:5a25:1::ae3:1101 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2078ms
rtt min/avg/max/mdev = 0.425/0.473/0.523/0.040 ms
访问主机网关地址正常。
2.3 测试到其他网段设备地址
bash-5.1$ ping6 2025:0207:5a25:4::10aa
PING 2025:0207:5a25:4::10aa(2025:0207:5a25:4::10aa) 56 data bytes
64 bytes from 2025:0207:5a25:4::10aa: icmp_seq=1 ttl=58 time=0.999 ms
64 bytes from 2025:0207:5a25:4::10aa: icmp_seq=2 ttl=58 time=0.726 ms
64 bytes from 2025:0207:5a25:4::10aa: icmp_seq=3 ttl=58 time=0.628 ms
64 bytes from 2025:0207:5a25:4::10aa: icmp_seq=4 ttl=58 time=0.735 ms
64 bytes from 2025:0207:5a25:4::10aa: icmp_seq=5 ttl=58 time=0.730 ms
^C
--- 2025:0207:5a25:4::10aa ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4064ms
rtt min/avg/max/mdev = 0.628/0.763/0.999/0.124 ms
bash-5.1$
测试正常,可以看到容器访问外部的IPV6设备完全正常,配置完成。