其他分享
首页 > 其他分享> > 确定容器和宿主机的网卡对应关系

确定容器和宿主机的网卡对应关系

作者:互联网

目录
注:这里我用的红帽的OpenShift环境

查看容器部分

[root@master ~]# oc get pods -o wide
NAME                       READY     STATUS    RESTARTS   AGE       IP              NODE
docker-registry-1-fv86x    1/1       Running   7          9d        10.130.0.47     node2.lab.example.com
docker-registry-1-l9vdg    1/1       Running   6          9d        10.128.0.48     node1.lab.example.com
registry-console-1-ptnzf   1/1       Running   6          9d        10.130.0.49     node2.lab.example.com
router-2-bjw22             1/1       Running   2          22h       172.25.250.11   node1.lab.example.com
router-2-j9wzs             1/1       Running   2          22h       172.25.250.12   node2.lab.example.com


# 进入node1上的一个容器中
[root@master ~]# oc rsh docker-registry-1-l9vdg

# 查看容器中eth0网卡的情况
sh-4.2$ ip a show eth0
3: eth0@if12: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UP 
    link/ether 0a:58:0a:80:00:30 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.128.0.48/23 brd 10.128.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::106c:39ff:fe96:bc48/64 scope link 
       valid_lft forever preferred_lft forever


# 查看容器中eth0网卡的连接情况
sh-4.2$ cat /sys/class/net/eth0/iflink 
12

查看宿主机部分

[root@node1 ~]# ip link show | grep ^12       ===> 查看上面iflink文件中的回显
12: vethe482d7bf@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master ovs-system state UP mode DEFAULT group default 


[root@node1 ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 52:54:00:00:fa:0b brd ff:ff:ff:ff:ff:ff
7: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default 
    link/ether 02:42:77:7a:cd:fe brd ff:ff:ff:ff:ff:ff
8: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether 9e:a9:97:87:2c:1c brd ff:ff:ff:ff:ff:ff
9: br0: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether da:69:c2:57:9b:4c brd ff:ff:ff:ff:ff:ff
10: vxlan_sys_4789: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65520 qdisc noqueue master ovs-system state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether da:b1:47:23:e4:f4 brd ff:ff:ff:ff:ff:ff
11: tun0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/ether ca:23:0b:df:e9:85 brd ff:ff:ff:ff:ff:ff
12: vethe482d7bf@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master ovs-system state UP mode DEFAULT group default      ===> 最前面的12是在容器中查iflink的结果
    link/ether c6:56:e5:c7:d2:4c brd ff:ff:ff:ff:ff:ff link-netnsid 0
13: veth4ce6db16@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master ovs-system state UP mode DEFAULT group default 
    link/ether 5a:e8:32:39:a5:fe brd ff:ff:ff:ff:ff:ff link-netnsid 1
14: vethf278820a@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master ovs-system state UP mode DEFAULT group default 
    link/ether 62:6d:75:44:81:77 brd ff:ff:ff:ff:ff:ff link-netnsid 2
15: vethfb4ef3ca@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc noqueue master ovs-system state UP mode DEFAULT group default 
    link/ether 5e:78:f2:4f:e2:11 brd ff:ff:ff:ff:ff:ff link-netnsid 3

其他参考

标签:容器,00,宿主机,mtu,网卡,state,link,ff,brd
来源: https://www.cnblogs.com/smlile-you-me/p/16520030.html