问题遇到的现象和发生背景
K8S中运行的一个容器,可以ping通我们公司内网网段172.16.XX.XX,但是在容器内无法ping通192.168.5.XX,但是我在宿主机是可以ping通192.168.5.XX,这个192.168.5.XX听网管说是通过什么VPN设备接进来的,所以可以在公司电脑或者我的宿主机直接ping通,但很奇怪在宿主机运行的docker容器却没办法ping通
下图为我宿主机的ip地址:
进入该容器
docker exec -it 044b132ecd51 /bin/sh
ping 192.168.5.10 ping不通
以下为跟踪信息:
/usr/local/s2i # traceroute 192.168.5.8 可以看到ping这个是ping不通
traceroute to 192.168.5.8 (192.168.5.8), 30 hops max, 46 byte packets
1 172-16-2-238.node-exporter.kubesphere-monitoring-system.svc.cluster.local (172.16.2.238) 0.006 ms 0.003 ms 0.003 ms
2 * * *
3 * *^C
/usr/local/s2i # traceroute 172.16.0.231 ping这些网段是可以的
traceroute to 172.16.0.231 (172.16.0.231), 30 hops max, 46 byte packets
1 172-16-2-238.node-exporter.kubesphere-monitoring-system.svc.cluster.local (172.16.2.238) 0.005 ms 0.003 ms 0.002 ms
2 172.16.2.1 (172.16.2.1) 1.744 ms 1.982 ms 1.522 ms
3 172.16.0.3 (172.16.0.3) 0.666 ms 0.647 ms 0.620 ms
4 172.16.0.231 (172.16.0.231) 0.660 ms 3.151 ms 2.575 ms
/usr/local/s2i # traceroute 172.17.0.1
traceroute to 172.17.0.1 (172.17.0.1), 30 hops max, 46 byte packets
1 172.17.0.1 (172.17.0.1) 0.005 ms 0.005 ms 0.002 ms
/usr/local/s2i # ipaddr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 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
2: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN qlen 1000
link/ipip 0.0.0.0 brd 0.0.0.0
4: eth0@if9: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1480 qdisc noqueue state UP
link/ether 82:06:25:b9:a9:22 brd ff:ff:ff:ff:ff:ff
inet 192.168.26.37/32 scope global eth0
valid_lft forever preferred_lft forever
/usr/local/s2i #
以下是我宿主机的docker网桥信息 用的都是默认的
[
{
"Name": "bridge",
"Id": "cd251d36987f690313634e20d0c453f427fb7ceb457c17513f3c96c58975f626",
"Created": "2022-06-01T17:16:44.57503358+08:00",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "172.17.0.0/16",
"Gateway": "172.17.0.1"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {},
"Options": {
"com.docker.network.bridge.default_bridge": "true",
"com.docker.network.bridge.enable_icc": "true",
"com.docker.network.bridge.enable_ip_masquerade": "true",
"com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
"com.docker.network.bridge.name": "docker0",
"com.docker.network.driver.mtu": "1500"
},
"Labels": {}
}
]
求看看,怎么解决这个问题?