List openvswitch virtual switch with ip command
I’ve configured openvswitch virtual switch and can list it with ip
command as follows:
# Show all interfaces
ip link
Output:
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
<snip>
5: ovs-system: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 8a:94:11:48:01:db brd ff:ff:ff:ff:ff:ff
6: ovsbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether e6:db:3f:88:4b:48 brd ff:ff:ff:ff:ff:ff
The openvswitch from this output is named ovsbr0
Now I want to use the ip
command to list only this virtual switch and exclude other interfaces, for example:
# List only bridges
ip link show type bridge
Expected output:
6: ovsbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether e6:db:3f:88:4b:48 brd ff:ff:ff:ff:ff:ff
Actual output:
<no output>
Why do I expect this command to output ovsbr0
?
This problem is specific to openvswitch
because if I use the same command to list bridges that are not openvswitch
then it works fine.
Example with a bridge that is created with ip
command:
# Create bridge named "br0"
sudo ip link add br0 type bridge
# Show the newly created bridge called "br0"
ip link show type bridge
Provides expected output:
7: br0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 6a:76:6f:50:da:35 brd ff:ff:ff:ff:ff:ff
As you can see the command works if the bridge is created with ip
command.
But it doesn’t work for openvswitch
Question:
- How do I use the
ip
command to list onlyopenvswitch
interfaces (virtual switches)? - Why the
ip
command does not work to listopenvswitch
interfaces (virtual switches)?
Additional context:
The openvswitch
was not created with ip
command, instead it was created with the ovs-vsctl command that is part of openvswitch
package:
sudo ovs-vsctl add-br ovsbr0
This openvswitch
bridge can however be deleted with ip
command just fine even though it was not created with ip
command:
# Delete it with ip command
sudo ip link delete ovsbr0
# Alternative and conventional method
sudo ovs-vsctl del-br ovsbr0
What have I tried:
# List openvswitch only but specifying type other than TYPE bridge
ip link show type TYPE
What are other interface types to test listing?
# See TYPE := section from this output for types other than "bridge"
ip link show help
The Open vSwitch interface is not a kernel bridge interface, but a kernel(-accelerated) openvswitch interface, with its own separate driver.
In case of doubt, any interface type will be displayed with the -details
option (edited to match OP):
$ ip -details link show dev ovsbr0
6: ovsbr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/ether e6:db:3f:88:4b:48 brd ff:ff:ff:ff:ff:ff promiscuity 1 allmulti 0 minmtu 68 maxmtu 65535
openvswitch numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535 tso_max_size 65536 tso_max_segs 65535 gro_max_size 65536 gso_ipv4_max_size 65536 gro_ipv4_max_size 65536
$ ip -details -json link show dev ovsbr0 | jq -r '.[].linkinfo.info_kind'
openvswitch
So naturally the command to display only this type is:
ip link show type openvswitch
This resource being developed separately from iproute2 one shouldn’t be surprised if the help doesn’t include it. For example, likewise, wireguard
doesn’t appear in the help, but a (kernel-based) WireGuard interface would be displayed using ip link show type wireguard
.