Skip to main content

Primary links

  • Home
  • AI
  • Kubernetes
  • Incus
  • Ansible
  • Terraform
  • OpenStack
  • Virtualization
  • Linux
  • SmartHome
  • HowTo

Misc

  • Linux
  • Hardware
  • Programming
  • Databases
  • Multimedia
  • Windows

Cloud

  • OpenStack
  • cloud-config
  • nextcloud

Virtualization

  • Virtualization
  • Incus
  • Docker
  • KVM
  • Kubernetes
  • LXC
  • LXD
  • QEMU
  • VMware
  • VirtualBox
  • multipass
  • podman
  • vagrant
  • XEN

Network

  • DNS
  • Firewall
  • Linux
  • OpenvSwitch
  • SSL
  • VLAN
  • VPN
  • iPXE
  • namespaces
  • nmcli
  • tcpdump

Storage

  • CEPH
  • DRBD
  • LVM
  • S3
  • ZFS
  • btrfs

Automation / CI/CD

  • Install
  • Ansible
  • GitLab
  • LLM
  • Preseed
  • Puppet
  • Terraform
  • Ubuntu autoinstall

Monitoring / Visualisation

  • Grafana
  • Icinga
  • Prometheus
  • Monitoring
  • ELK
  • mermaid

Check OpenvSwitch

#!/bin/bash

export OS_ENV="@globals.environment@"


if [ "${OS_ENV}" == "dev" ]; then
    export PYENV_ROOT="$HOME/.pyenv"
    export PATH="$PYENV_ROOT/bin:$PATH"
    eval "$(pyenv init -)"
fi

source /etc/kolla/admin-openrc.sh

EXIT_CODE=0

# search for broken ovs entry in DB
for NODE in $(openstack compute service list -c Host -f value | sort -u); do
    OUTPUT=$(ssh ${NODE} docker exec openvswitch_vswitchd ovsdb-client dump | grep qvo | egrep -v "tag|mac" | cut -d "\"" -f2)
    for PORT in ${OUTPUT}; do
        printf "%-20s %s\n" "${NODE}" "${PORT}"

        EXIT_CODE=1
    done
done

# Search for "No such device" OpenvSwitch ports
for NODE in $(openstack compute service list -c Host -f value | sort -u); do
    OUTPUT="$(ssh ${NODE} docker exec -i openvswitch_vswitchd ovs-vsctl show | grep "No such device")"
    if [ -n "${OUTPUT}" ]; then
        echo "${NODE}"
        echo "${OUTPUT}"

        EXIT_CODE=1
    fi
done

# search for unnecessary Open vSwitch interfaces on physical hosts
for NODE in $(openstack compute service list -c Host -f value | sort -u); do
    for PORT_TOKEN in $(ssh ${NODE} brctl show | egrep "qvb|tap" | sed '$!N;/\n.*tap/d;P;D' | awk '{print substr($1,4,8)}'); do
        PORT_ID=$(openstack port list -c id -f value | grep ${PORT_TOKEN})
        if [ -n "${PORT_ID}" ]; then
            SERVER_ID=$(openstack port show -c device_id -f value ${PORT_ID})
            SERVER_STATUS=$(openstack server show -c status -f value ${SERVER_ID})
            if [ "${SERVER_STATUS}" != "SHUTOFF" ] && [ "${SERVER_STATUS}" != "VERIFY_RESIZE" ]; then
                echo "NODE: ${NODE}"
                echo "PORT_TOKEN: ${PORT_TOKEN}"
                openstack server show -c name -c id -c project_id -c status ${SERVER_ID}

                EXIT_CODE=1
            fi
        else

OpenVswitch: cleanup interfaces without tap device

Show bridges without tab device

brctl show | egrep "qvb|tap" | sed '$!N;/\n.*tap/d;P;D' | awk '{print substr($1,4,8)}'

Get interface details

TOKEN=cac559da

# show port details
docker exec openvswitch_vswitchd ovsdb-client dump | grep ${TOKEN}

# get OVS port
docker exec openvswitch_vswitchd ovs-vsctl list-ports br-int | grep ${TOKEN}

# get OVS interface
docker exec openvswitch_vswitchd ovs-vsctl list-ifaces br-int | grep ${TOKEN}

# show host bridges
brctl show | grep ${TOKEN}

# show host interfaces
ip a | grep ${TOKEN}

Delete interface

PORT_TOKEN=a101dd83

# get port ID
PORT_ID=$(docker exec openvswitch_vswitchd ovs-vsctl list-ports br-int | grep ${PORT_TOKEN})
echo ${PORT_ID}

# remove port
docker exec openvswitch_vswitchd ovs-vsctl del-port br-int ${PORT_ID}

# remove bridge
BRIDGE_ID=${PORT_ID/qvo/qbr}
echo ${BRIDGE_ID}
ip link set ${BRIDGE_ID} down
brctl delbr ${BRIDGE_ID}

# remove interface
ip link delete ${PORT_ID}

Openstack: Debug networking

Video: OpenStack Neutron Packet Walkthrough (DVR) by David Mahler
https://www.youtube.com/watch?v=7IXEtUEZslg

SERVER_ID=11111111-2222-3333-4444-555555555555

nova interface-list ${SERVER_ID}

PORT_TOKEN=$(nova interface-list ${SERVER_ID} | grep ACTIVE | cut -d "|" -f3 | cut -d"-" -f1)
echo PORT_TOKEN=${PORT_TOKEN}

COMPUTE_NODE=$(openstack server show -c "OS-EXT-SRV-ATTR:hypervisor_hostname" -f value ${SERVER_ID})
echo ${COMPUTE_NODE}

ssh ${COMPUTE_NODE} brctl show | grep ${PORT_TOKEN}
TAP_DEVICE=$(ssh ${COMPUTE_NODE} brctl show | grep ${PORT_TOKEN} | grep tap)

TAP_DEVICE=$(ssh ${COMPUTE_NODE} brctl show | grep ${PORT_TOKEN} | grep tap)
echo ${TAP_DEVICE}

# second console
echo tcpdump -i ${TAP_DEVICE} -n -e icmp
ssh ${COMPUTE_NODE}



# 3th console
ssh ${COMPUTE_NODE}
iptables -S | grep o${PORT_TOKEN} | grep ${PORT_TOKEN}
# todo:
iptables -S neutron-openvswi-s${PORT_TOKEN}-f

iptables -S neutron-openvswi-sg-chain | grep #${PORT_TOKEN}

docker exec -it openvswitch_vswitchd bash
ovs-vsctl show

ovs-vsctl show | grep -U1 ${PORT_TOKEN}

# NORMAL missiong
watch -n .5 "ovs-ofctl dump-flows br-int table=0 | grep -v n_packets=0"


ovs-appctl -t /var/run/openvswitch/ovs-vswitchd.*.ctl fdb/show br-int | egrep "MAC|fa:11:22:33:44:55"

ovs-ofctl show br-int | grep 293 -A5

brctl show | grep qvo${PORT_TOKEN}-fb

Notes

LXD with OpenvSwitch network

# create bridge
ovs-vsctl add-br mybridge
# ifconfig mybridge up
ip link set mybridge up
ovs-vsctl show

# connect ovs bridge to external network
ovs-vsctl add-port mybridge eno1
ifconfig eno1 0
dhclient mybridge -v
ip a show mybridge
route -n

# create LXD container
lxc profile create disk-only
lxc storage create pool1 dir
lxc profile device add disk-only root disk path=/ pool=pool1
lxc profile show disk-only
lxc launch ubuntu:18.04 ovs1 -p disk-only
lxc config device add ovs1 eth0 nic nictype=bridged parent=mybridge host_name=vport11
lxc launch ubuntu:18.04 ovs2 -p disk-only
lxc config device add ovs2 eth0 nic nictype=bridged parent=mybridge host_name=vport12
lxc network list

OpenStack: OpenvSwitch

Get VM data

# OPTINAL: find VM name
# openstack server list --all | grep XXX

# get FROM VM ID
SERVER_STRING=www-dev
SERVER_ID=$(openstack server list --all --name ${SERVER_STRING} -c ID -f value)
echo ${SERVER_ID}

SERVER_IP_ADDRESS=10.0.0

PORT_TOKEN=$(nova interface-list ${SERVER_ID} | grep ${SERVER_IP_ADDRESS} | awk -F'|' '/ACTIVE/ {gsub(/ /,"",$3); print substr($3,0,9)}')
NETWORK_TOKEN=$(nova interface-list ${SERVER_ID} | grep ${SERVER_IP_ADDRESS} | awk -F'|' '/ACTIVE/ {gsub(/ /,"",$4); print substr($4,0,9)}')
SERVER_NAME=$(openstack server show ${SERVER_ID} -c name -f value)
SERVER_IP=$(nova interface-list ${SERVER_ID} | grep ${SERVER_IP_ADDRESS} | awk -F'|' '/ACTIVE/ {gsub(/ /,"",$5); print $5}')
SERVER_MAC=$(nova interface-list ${SERVER_ID} | grep ${SERVER_IP_ADDRESS} | awk -F'|' '/ACTIVE/ {gsub(/ /,"",$6); print $6}')
COMPUTE_NODE=$(openstack server show -c "OS-EXT-SRV-ATTR:hypervisor_hostname" -f value ${SERVER_ID})
SERVER_DEV=$(ssh ${COMPUTE_NODE} brctl show | grep ${PORT_TOKEN} | paste - - | sed -e 's/[\t]/ /g;s/  */ /g' | awk '{print $5" "$4}')

# show server data
echo "
SERVER_NAME: ${SERVER_NAME}
SERVER_ID: ${SERVER_ID}
SERVER_IP: ${SERVER_IP}
SERVER_MAC: ${SERVER_MAC}
SERVER_DEV: ${SERVER_DEV}
PORT_TOKEN: ${PORT_TOKEN}
NETWORK_TOKEN: ${NETWORK_TOKEN}
COMPUTE_NODE: ${COMPUTE_NODE}
"

Search for broken openvswitch devices

Open vSwitch (OVS)

Install

apt install -y openvswitch-switch

List

# list interfaces
docker exec openvswitch_vswitchd ovs-vsctl list-ifaces br-int

# show bridges
docker exec openvswitch_vswitchd ovs-vsctl list-br

# show ports
docker exec openvswitch_vswitchd ovs-vsctl list-ports br-int

Create interface
https://docs.openstack.org/octavia/latest/install/install-ubuntu.html

# create bridge
ovs-vsctl add-br mybridge
# ifconfig mybridge up
ip link set mybridge up
ovs-vsctl show
ovs-dpctl show

# create
echo docker exec openvswitch_vswitchd ovs-vsctl -- --may-exist add-port br-int my-if1 -- \
set Interface my-if1 type=internal -- \
set Interface my-if1 external-ids:iface-status=active -- \
set Interface my-if1 external-ids:attached-mac=${CTL_HOST_MAC} -- \
set Interface my-if1 external-ids:iface-id=${PORT_ID} -- \
set Interface my-if1 external-ids:skip_cleanup=true

# Create port
openvswitch_vswitchd ovs-vsctl -- --may-exist add-port br-int my-port1 -- \
    set Interface o-hm0 type=internal -- \
    set Interface o-hm0 mac="${PORT_MAC}" -- \
    set Interface o-hm0 external-ids:iface-status=active -- \
    set Interface o-hm0 external-ids:iface-id=${PORT_ID} -- \
    set Interface o-hm0 external-ids:skip_cleanup=true -- \
    set Interface o-hm0 external-ids:attached-mac=${PORT_MAC}

# create vlan
ovs-vsctl add-port br0 vlan10 tag=10 -- set Interface vlan10 type=internal
ip addr add 192.168.0.123/24 dev vlan10

Show / List

ovs-vsctl show

ovs-vsctl list bridge
ovs-vsctl list port
ovs-vsctl list interface

Create

ovs-vsctl -- --may-exist add-port br-int o-hm0 -- \
set Interface o-hm0 type=internal -- \
set Interface o-hm0 external-ids:iface-status=active -- \
set Interface o-hm0 external-ids:attached-mac=${CTL_HOST_MAC} -- \
set Interface o-hm0 external-ids:iface-id=${PORT_ID} -- \
set Interface o-hm0 external-ids:skip_cleanup=true

Delete

# delete port
ovs-vsctl del-port br-int o-hm0

# delete ovs-tcpdump port
ovs-vsctl del-port br-tun ovsmiXXXXXX

# delete bridge
ovs-vsctl del-br mybridge

CLI
http://www.sznote.net/?p=1032

openvswitch
Profiles GitHub StackOverflow LinkedIn Xing
Contact Imprint
© panticz 2026

Cookie-Einstellungen

Diese Website nutzt eingebettete Inhalte von Drittanbietern (z.B. YouTube, SoundCloud). Beim Laden dieser Inhalte werden Daten an die jeweiligen Anbieter übermittelt. Datenverarbeitungserklärung