veth pair: How to know what interfaces are connected by a veth pair?

Published: by

  • Categories:

Here is a quick one. Couldn't find a direct solution on Google.

You can find out what's the peer of a interface by issuing the command:

[root@compute-1 ~]# sudo ethtool -S int-br-ex
NIC statistics:
     peer_ifindex: 55
[root@compute-1 ~]# ip link  | grep 55:
    link/ether c6:5f:55:82:20:72 brd ff:ff:ff:ff:ff:ff
55: phy-br-ex:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
[root@compute-1 ~]#

So, you can easily find out that int-br-ex and phy-br-ex are peer to each other, that means they are connected via veth pair. To find out what all veth pairs are present in your system:

[root@compute-1 ~]# ip -d link show
.... output omitted ...
55: phy-br-ex:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 52:92:8e:3f:6e:f8 brd ff:ff:ff:ff:ff:ff
    veth 
56: int-br-ex:  mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether d6:3b:77:c0:70:4f brd ff:ff:ff:ff:ff:ff
    veth
[root@compute-1 ~]#

While using "-d" option, ip command gives you a little more details about the interface. In this case, it tells you whether a interface is part of a veth pair.