Open Vswitch Projekt: Unterschied zwischen den Versionen
| (45 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
| − | = Open vSwitch (OVS) als Cisco-ähnlicher L2-Switch mit Management-IP = | + | == Open vSwitch (OVS) als Cisco-ähnlicher L2-Switch mit Management-IP == |
== Ziel == | == Ziel == | ||
In diesem Artikel wird beschrieben, wie man unter Linux mit Open vSwitch (OVS) eine Schulungsumgebung aufbaut, die einem Cisco Catalyst oder Nexus Switch ähnelt. | In diesem Artikel wird beschrieben, wie man unter Linux mit Open vSwitch (OVS) eine Schulungsumgebung aufbaut, die einem Cisco Catalyst oder Nexus Switch ähnelt. | ||
Funktionen im ersten Schritt: | Funktionen im ersten Schritt: | ||
| − | * bis zu 18 Interfaces ( | + | * bis zu 18 Interfaces (port1–port18) |
* VLANs (1, 21, 22, 23) | * VLANs (1, 21, 22, 23) | ||
* 1 Trunk-Port mit VLAN 1 (native untagged) + VLANs 21/22/23 getaggt | * 1 Trunk-Port mit VLAN 1 (native untagged) + VLANs 21/22/23 getaggt | ||
| Zeile 13: | Zeile 13: | ||
== Voraussetzungen == | == Voraussetzungen == | ||
| − | * Debian | + | * Debian 13 |
| − | * Linux-VM mit ≥ 18 Netzwerkkarten ( | + | * Linux-VM mit ≥ 18 Netzwerkkarten (port1–port18) |
* Root-Zugriff | * Root-Zugriff | ||
* In VirtualBox/KVM: alle NICs auf '''Promiscuous Mode: Allow All''' | * In VirtualBox/KVM: alle NICs auf '''Promiscuous Mode: Allow All''' | ||
| + | == Hostname setzen == | ||
| + | hostnamectl set-hostname ovs.lab.int | ||
== Installation == | == Installation == | ||
| − | + | <pre> | |
| − | + | apt update | |
| + | apt install openvswitch-switch snmpd snmp | ||
| + | </pre> | ||
| − | == | + | == Netzwerkinterfaces umbenennen (port1–port24) == |
| − | + | Die Netzwerkinterfaces werden per '''udev'''-Regel dauerhaft und zuverlässig in '''port1–port24''' umbenannt. | |
| + | Die Benennung erfolgt anhand der '''PCI-Bus-Adresse''' — dadurch funktionieren die Regeln auch nach einem Klon ohne Änderung. | ||
| − | == | + | === Regeln in der VM generieren === |
| − | + | <pre> | |
| + | i=1 | ||
| + | for pci in $(lspci | grep Ethernet | awk '{print $1}'); do | ||
| + | echo "SUBSYSTEM==\"net\", ACTION==\"add\", KERNELS==\"0000:$pci\", NAME=\"port$i\"" | ||
| + | ((i++)) | ||
| + | done > /etc/udev/rules.d/10-ovs-nics.rules | ||
| + | </pre> | ||
| − | == | + | === Kontrolle === |
| − | + | <pre> | |
| − | + | cat /etc/udev/rules.d/10-ovs-nics.rules | |
| − | + | </pre> | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | == | + | === Änderungen aktivieren === |
| − | + | <pre> | |
| + | udevadm control --reload-rules | ||
| + | reboot | ||
| + | </pre> | ||
| − | + | == Interfaces per /etc/network/interfaces konfigurieren == | |
| + | port1–port23 werden als '''manual''' eingetragen — kein DHCP, keine IP, nur den Link bereitstellen für OVS. | ||
| + | port24 ist der NAT-Konsolen-Port und läuft außerhalb von OVS per DHCP: | ||
<pre> | <pre> | ||
| + | cat > /etc/network/interfaces << 'EOF' | ||
| + | source /etc/network/interfaces.d/* | ||
| + | |||
auto lo | auto lo | ||
iface lo inet loopback | iface lo inet loopback | ||
| − | + | auto port1 | |
| − | auto | + | iface port1 inet manual |
| − | iface | + | |
| − | auto | + | auto port2 |
| − | iface | + | iface port2 inet manual |
| − | auto | + | |
| − | iface | + | auto port3 |
| − | auto | + | iface port3 inet manual |
| − | iface | + | |
| − | auto | + | auto port4 |
| − | iface | + | iface port4 inet manual |
| − | auto | + | |
| − | iface | + | auto port5 |
| − | auto | + | iface port5 inet manual |
| − | iface | + | |
| − | auto | + | auto port6 |
| − | iface | + | iface port6 inet manual |
| − | auto | + | |
| − | iface | + | auto port7 |
| − | auto | + | iface port7 inet manual |
| − | iface | + | |
| − | auto | + | auto port8 |
| − | iface | + | iface port8 inet manual |
| − | auto | + | |
| − | iface | + | auto port9 |
| − | auto | + | iface port9 inet manual |
| − | iface | + | |
| − | auto | + | auto port10 |
| − | iface | + | iface port10 inet manual |
| − | auto | + | |
| − | iface | + | auto port11 |
| − | auto | + | iface port11 inet manual |
| − | iface | + | |
| − | auto | + | auto port12 |
| − | iface | + | iface port12 inet manual |
| + | |||
| + | auto port13 | ||
| + | iface port13 inet manual | ||
| + | |||
| + | auto port14 | ||
| + | iface port14 inet manual | ||
| + | |||
| + | auto port15 | ||
| + | iface port15 inet manual | ||
| + | |||
| + | auto port16 | ||
| + | iface port16 inet manual | ||
| + | |||
| + | auto port17 | ||
| + | iface port17 inet manual | ||
| + | |||
| + | auto port18 | ||
| + | iface port18 inet manual | ||
| + | |||
| + | auto port19 | ||
| + | iface port19 inet manual | ||
| + | |||
| + | auto port20 | ||
| + | iface port20 inet manual | ||
| + | |||
| + | auto port21 | ||
| + | iface port21 inet manual | ||
| + | |||
| + | auto port22 | ||
| + | iface port22 inet manual | ||
| + | |||
| + | auto port23 | ||
| + | iface port23 inet manual | ||
| + | |||
| + | auto port24 | ||
| + | iface port24 inet dhcp | ||
| + | |||
| + | EOF | ||
| + | |||
| + | </pre> | ||
| + | |||
| + | === Änderungen aktivieren === | ||
| + | <pre> | ||
| + | udevadm control --reload-rules | ||
| + | reboot | ||
| + | </pre> | ||
| + | |||
| + | === Kontrolle nach dem Reboot === | ||
| + | <pre> | ||
| + | ip link show | ||
| + | </pre> | ||
| + | Erwartete Ausgabe: Interfaces '''port1''' bis '''port18''' sind sichtbar. | ||
| − | + | == OVS-Bridge anlegen == | |
| − | + | <pre> | |
| − | + | ovs-vsctl add-br sw0 | |
| + | </pre> | ||
| + | |||
| + | == Trunk-Port konfigurieren (z. B. Richtung OPNsense/Router) == | ||
| + | <pre> | ||
| + | ovs-vsctl add-port sw0 port1 tag=1 trunks=21,22,23 vlan_mode=native-untagged | ||
| + | </pre> | ||
| + | |||
| + | == Access-Ports konfigurieren == | ||
| + | ;Tabelle | ||
| + | {| class="wikitable" | ||
| + | ! Port(s) !! Typ !! VLAN(s) !! Bestimmung | ||
| + | |- | ||
| + | | '''port1''' || '''Trunk''' || 1 (Untagged), 21, 22, 23 (Tagged) || Uplink zu Router / OPNsense | ||
| + | |- | ||
| + | | '''port2 – 10''' || Access || 21 (DMZ) || Server-Zone / DMZ | ||
| + | |- | ||
| + | | '''port11 – 15''' || Access || 22 (LAN) || Client-Netz | ||
| + | |- | ||
| + | | '''port16 – 20''' || Access || 23 (Server) || Interne Dienste | ||
| + | |- | ||
| + | | '''port21 – 22''' || Access || 1 (Management) || Reserve / Admin-Geräte | ||
| + | |- | ||
| + | | '''port23''' || '''Mirror''' || Alle (SPAN) || IDS / Monitoring / Wireshark | ||
| + | |- | ||
| + | | '''port24''' || '''Out-of-Band''' || – || Management-Konsole (Host-NAT) | ||
| + | |} | ||
| + | ;Befehle | ||
| + | |||
| + | <pre> | ||
| + | ovs-vsctl add-port sw0 port2 tag=21 | ||
| + | ovs-vsctl add-port sw0 port3 tag=21 | ||
| + | ovs-vsctl add-port sw0 port4 tag=21 | ||
| + | ovs-vsctl add-port sw0 port5 tag=21 | ||
| + | ovs-vsctl add-port sw0 port6 tag=21 | ||
| + | ovs-vsctl add-port sw0 port7 tag=21 | ||
| + | ovs-vsctl add-port sw0 port8 tag=21 | ||
| + | ovs-vsctl add-port sw0 port9 tag=21 | ||
| + | ovs-vsctl add-port sw0 port10 tag=21 | ||
| + | ovs-vsctl add-port sw0 port11 tag=22 | ||
| + | ovs-vsctl add-port sw0 port12 tag=22 | ||
| + | ovs-vsctl add-port sw0 port13 tag=22 | ||
| + | ovs-vsctl add-port sw0 port14 tag=22 | ||
| + | ovs-vsctl add-port sw0 port15 tag=22 | ||
| + | ovs-vsctl add-port sw0 port16 tag=23 | ||
| + | ovs-vsctl add-port sw0 port17 tag=23 | ||
| + | ovs-vsctl add-port sw0 port18 tag=23 | ||
| + | ovs-vsctl add-port sw0 port19 tag=23 | ||
| + | ovs-vsctl add-port sw0 port20 tag=23 | ||
| + | ovs-vsctl add-port sw0 port21 tag=1 | ||
| + | ovs-vsctl add-port sw0 port22 tag=1 | ||
| + | </pre> | ||
| + | |||
| + | == Interface der VLANs anlegen == | ||
| + | |||
| + | <pre> | ||
| + | ovs-vsctl add-port sw0 mgmt tag=1 -- set interface mgmt type=internal | ||
| + | ovs-vsctl add-port sw0 dmz tag=21 -- set interface dmz type=internal | ||
| + | ovs-vsctl add-port sw0 lan tag=22 -- set interface lan type=internal | ||
| + | ovs-vsctl add-port sw0 server tag=23 -- set interface server type=internal | ||
| + | </pre> | ||
| + | |||
| + | Management-IP per '''/etc/network/interfaces''' setzen: | ||
| + | <pre> | ||
| + | cat >> /etc/network/interfaces << 'EOF' | ||
| − | |||
auto mgmt | auto mgmt | ||
iface mgmt inet static | iface mgmt inet static | ||
address 172.26.56.2/26 | address 172.26.56.2/26 | ||
gateway 172.26.56.1 | gateway 172.26.56.1 | ||
| + | dns-nameservers 172.26.56.1 | ||
| + | dns-search it2XX.int | ||
| + | EOF | ||
| + | |||
| + | ifup mgmt | ||
</pre> | </pre> | ||
| − | + | == Mirror-Port konfigurieren (SPAN) == | |
| + | port23 dient als Mirror-Ausgang — dort kann ein IDS oder Wireshark angeschlossen werden: | ||
<pre> | <pre> | ||
| − | ovs-vsctl -- --id=@m create Mirror name=mirror0 \ | + | ovs-vsctl add-port sw0 port23 |
| − | + | ovs-vsctl -- --id=@p get port port23 \ | |
| − | + | -- --id=@m create Mirror name=mirror0 \ | |
| − | + | select-all=true \ | |
| + | select-vlan=21,22,23 \ | ||
| + | output-port=@p \ | ||
| + | -- set Bridge sw0 mirrors=@m | ||
</pre> | </pre> | ||
| Zeile 117: | Zeile 247: | ||
* name: mirror0 | * name: mirror0 | ||
* select-vlan: [1,21,22,23] | * select-vlan: [1,21,22,23] | ||
| − | * output-port: | + | * output-port: port23 |
=== Nutzung === | === Nutzung === | ||
| − | * An '' | + | * An '''port23''' wird ein IDS oder ein Analyse-System (z. B. Wireshark/tcpdump) angeschlossen |
| − | * Dort ist der gesamte Traffic der VLANs | + | * Dort ist der gesamte Traffic der VLANs 21, 22 und 23 sichtbar |
== SNMPv3 konfigurieren == | == SNMPv3 konfigurieren == | ||
| − | Datei '''/etc/snmp/snmpd.conf''' anpassen: | + | ;Datei '''/etc/snmp/snmpd.conf''' anpassen: |
| + | <pre> | ||
| + | ########################################################################### | ||
| + | # SECTION: System Information | ||
| + | ########################################################################### | ||
| + | sysLocation Lab | ||
| + | sysContact admin <admin@lab.int> | ||
| + | sysServices 72 | ||
| + | |||
| + | ########################################################################### | ||
| + | # SECTION: Agent Operating Mode | ||
| + | ########################################################################### | ||
| + | master agentx | ||
| + | agentaddress udp:161,udp6:161 | ||
| + | |||
| + | ########################################################################### | ||
| + | # SECTION: Access Control | ||
| + | ########################################################################### | ||
| + | |||
| + | # View: alles unterhalb der MIB-Wurzel | ||
| + | view full included .1 | ||
| + | |||
| + | # SNMPv1/v2c deaktiviert - keine rocommunity Einträge | ||
| + | |||
| + | # SNMPv3 User | ||
| + | createUser ovsuser SHA "123Start$" AES "Passw0rd" | ||
| + | rouser ovsuser authPriv -V full | ||
| + | |||
| + | includeDir /etc/snmp/snmpd.conf.d | ||
| + | HERE | ||
| + | </pre> | ||
| + | |||
| + | ;Restart | ||
| + | systemctl restart snmpd | ||
| + | ;Test der SNMPv3-Abfrage: | ||
<pre> | <pre> | ||
| − | + | snmpwalk -v3 -u ovsuser -l authPriv -a SHA -A 123Start$ -x AES -X Passw0rd localhost | |
| − | |||
</pre> | </pre> | ||
| − | + | == Wichtige Befehle == | |
| − | |||
| − | + | === OVS-Diagnose === | |
| − | |||
| − | + | Zeigt die komplette OVS-Bridge-Konfiguration (Bridges, Ports, VLAN-Tags). | |
| − | Zeigt die komplette OVS-Bridge-Konfiguration (Bridges, Ports, VLAN-Tags). | ||
* '''ovs-vsctl show''' | * '''ovs-vsctl show''' | ||
| − | Listet alle Ports, die an der Bridge '' | + | Listet alle Ports, die an der Bridge ''sw0'' hängen. |
| − | * '''ovs-vsctl list-ports | + | * '''ovs-vsctl list-ports sw0''' |
| − | Zeigt Details zum Port '' | + | Zeigt Details zum Port ''port2'' (inklusive VLAN-Tag). |
| − | * '''ovs-vsctl list interface | + | * '''ovs-vsctl list interface port2''' |
| − | Zeigt, welche VLANs auf dem Trunk-Port '' | + | Zeigt, welche VLANs auf dem Trunk-Port ''port1'' erlaubt sind. |
| − | * '''ovs-vsctl get port | + | * '''ovs-vsctl get port port1 trunks''' |
| − | Zeigt den Zustand der Datenebene (DPIF-Interfaces, OpenFlow). | + | Zeigt den Zustand der Datenebene (DPIF-Interfaces, OpenFlow). |
* '''ovs-dpctl show''' | * '''ovs-dpctl show''' | ||
| − | Zeigt die Forwarding Database (FDB), ähnlich wie | + | Zeigt die Forwarding Database (FDB), ähnlich wie ''show mac address-table'' auf Cisco. |
| − | * '''ovs-appctl fdb/show | + | * '''ovs-appctl fdb/show sw0''' |
| − | Zeigt vorhandene SPAN/Mirror-Konfigurationen. | + | Zeigt vorhandene SPAN/Mirror-Konfigurationen. |
| − | * '''ovs-appctl mirror/list | + | * '''ovs-appctl mirror/list sw0''' |
=== VLAN-Konfiguration ändern === | === VLAN-Konfiguration ändern === | ||
| − | |||
| − | |||
| − | Setzt '' | + | Setzt ''port2'' als Access-Port im VLAN 10 (untagged). |
| − | * '''ovs-vsctl set port | + | * '''ovs-vsctl set port port2 tag=10''' |
| + | |||
| + | Setzt ''port3'' als Trunk-Port für VLAN 10, 20 und 30 (getagged). | ||
| + | * '''ovs-vsctl set port port3 trunks=10,20,30''' | ||
| − | Setzt '' | + | Setzt ''port3'' als Trunk-Port, VLAN 10 untagged (native), VLAN 20 und 30 getagged. |
| − | * '''ovs-vsctl set port | + | * '''ovs-vsctl set port port3 tag=10 trunks=20,30''' |
| − | Entfernt VLAN-Zuweisung von '' | + | Entfernt VLAN-Zuweisung von ''port2'' bzw. VLAN 20 von ''port3''. |
| − | * '''ovs-vsctl remove port | + | * '''ovs-vsctl remove port port2 tag''' |
| − | * '''ovs-vsctl remove port | + | * '''ovs-vsctl remove port port3 trunks 20''' |
== Ergebnis == | == Ergebnis == | ||
| − | * ''' | + | * '''port1''' = Trunk (VLAN 1 native untagged, VLAN 21/22/23 getaggt) |
| − | * ''' | + | * '''port2–port22''' = Access-Ports (je VLAN, untagged) — 14 für VMs, 2 Reserve |
| − | * ''' | + | * '''port23''' = Mirror/SPAN-Ausgang (außerhalb OVS) |
| + | * '''port24''' = NAT-Konsolen-Port, DHCP (außerhalb OVS, SSH Port 2222) | ||
* '''mgmt''' = Management-Port im VLAN 1 mit IP 172.26.56.2/26 | * '''mgmt''' = Management-Port im VLAN 1 mit IP 172.26.56.2/26 | ||
| − | |||
* '''SNMPv3''' = Überwachung aller Interfaces möglich | * '''SNMPv3''' = Überwachung aller Interfaces möglich | ||
Aktuelle Version vom 15. Mai 2026, 08:39 Uhr
Open vSwitch (OVS) als Cisco-ähnlicher L2-Switch mit Management-IP
Ziel
In diesem Artikel wird beschrieben, wie man unter Linux mit Open vSwitch (OVS) eine Schulungsumgebung aufbaut, die einem Cisco Catalyst oder Nexus Switch ähnelt. Funktionen im ersten Schritt:
- bis zu 18 Interfaces (port1–port18)
- VLANs (1, 21, 22, 23)
- 1 Trunk-Port mit VLAN 1 (native untagged) + VLANs 21/22/23 getaggt
- mehrere Access-Ports (je ein VLAN)
- 1 Mirror-Port (SPAN)
- SNMPv3 zur Überwachung
- Management-IP im VLAN 1
Voraussetzungen
- Debian 13
- Linux-VM mit ≥ 18 Netzwerkkarten (port1–port18)
- Root-Zugriff
- In VirtualBox/KVM: alle NICs auf Promiscuous Mode: Allow All
Hostname setzen
hostnamectl set-hostname ovs.lab.int
Installation
apt update apt install openvswitch-switch snmpd snmp
Netzwerkinterfaces umbenennen (port1–port24)
Die Netzwerkinterfaces werden per udev-Regel dauerhaft und zuverlässig in port1–port24 umbenannt. Die Benennung erfolgt anhand der PCI-Bus-Adresse — dadurch funktionieren die Regeln auch nach einem Klon ohne Änderung.
Regeln in der VM generieren
i=1
for pci in $(lspci | grep Ethernet | awk '{print $1}'); do
echo "SUBSYSTEM==\"net\", ACTION==\"add\", KERNELS==\"0000:$pci\", NAME=\"port$i\""
((i++))
done > /etc/udev/rules.d/10-ovs-nics.rules
Kontrolle
cat /etc/udev/rules.d/10-ovs-nics.rules
Änderungen aktivieren
udevadm control --reload-rules reboot
Interfaces per /etc/network/interfaces konfigurieren
port1–port23 werden als manual eingetragen — kein DHCP, keine IP, nur den Link bereitstellen für OVS. port24 ist der NAT-Konsolen-Port und läuft außerhalb von OVS per DHCP:
cat > /etc/network/interfaces << 'EOF' source /etc/network/interfaces.d/* auto lo iface lo inet loopback auto port1 iface port1 inet manual auto port2 iface port2 inet manual auto port3 iface port3 inet manual auto port4 iface port4 inet manual auto port5 iface port5 inet manual auto port6 iface port6 inet manual auto port7 iface port7 inet manual auto port8 iface port8 inet manual auto port9 iface port9 inet manual auto port10 iface port10 inet manual auto port11 iface port11 inet manual auto port12 iface port12 inet manual auto port13 iface port13 inet manual auto port14 iface port14 inet manual auto port15 iface port15 inet manual auto port16 iface port16 inet manual auto port17 iface port17 inet manual auto port18 iface port18 inet manual auto port19 iface port19 inet manual auto port20 iface port20 inet manual auto port21 iface port21 inet manual auto port22 iface port22 inet manual auto port23 iface port23 inet manual auto port24 iface port24 inet dhcp EOF
Änderungen aktivieren
udevadm control --reload-rules reboot
Kontrolle nach dem Reboot
ip link show
Erwartete Ausgabe: Interfaces port1 bis port18 sind sichtbar.
OVS-Bridge anlegen
ovs-vsctl add-br sw0
Trunk-Port konfigurieren (z. B. Richtung OPNsense/Router)
ovs-vsctl add-port sw0 port1 tag=1 trunks=21,22,23 vlan_mode=native-untagged
Access-Ports konfigurieren
- Tabelle
| Port(s) | Typ | VLAN(s) | Bestimmung |
|---|---|---|---|
| port1 | Trunk | 1 (Untagged), 21, 22, 23 (Tagged) | Uplink zu Router / OPNsense |
| port2 – 10 | Access | 21 (DMZ) | Server-Zone / DMZ |
| port11 – 15 | Access | 22 (LAN) | Client-Netz |
| port16 – 20 | Access | 23 (Server) | Interne Dienste |
| port21 – 22 | Access | 1 (Management) | Reserve / Admin-Geräte |
| port23 | Mirror | Alle (SPAN) | IDS / Monitoring / Wireshark |
| port24 | Out-of-Band | – | Management-Konsole (Host-NAT) |
- Befehle
ovs-vsctl add-port sw0 port2 tag=21 ovs-vsctl add-port sw0 port3 tag=21 ovs-vsctl add-port sw0 port4 tag=21 ovs-vsctl add-port sw0 port5 tag=21 ovs-vsctl add-port sw0 port6 tag=21 ovs-vsctl add-port sw0 port7 tag=21 ovs-vsctl add-port sw0 port8 tag=21 ovs-vsctl add-port sw0 port9 tag=21 ovs-vsctl add-port sw0 port10 tag=21 ovs-vsctl add-port sw0 port11 tag=22 ovs-vsctl add-port sw0 port12 tag=22 ovs-vsctl add-port sw0 port13 tag=22 ovs-vsctl add-port sw0 port14 tag=22 ovs-vsctl add-port sw0 port15 tag=22 ovs-vsctl add-port sw0 port16 tag=23 ovs-vsctl add-port sw0 port17 tag=23 ovs-vsctl add-port sw0 port18 tag=23 ovs-vsctl add-port sw0 port19 tag=23 ovs-vsctl add-port sw0 port20 tag=23 ovs-vsctl add-port sw0 port21 tag=1 ovs-vsctl add-port sw0 port22 tag=1
Interface der VLANs anlegen
ovs-vsctl add-port sw0 mgmt tag=1 -- set interface mgmt type=internal ovs-vsctl add-port sw0 dmz tag=21 -- set interface dmz type=internal ovs-vsctl add-port sw0 lan tag=22 -- set interface lan type=internal ovs-vsctl add-port sw0 server tag=23 -- set interface server type=internal
Management-IP per /etc/network/interfaces setzen:
cat >> /etc/network/interfaces << 'EOF'
auto mgmt
iface mgmt inet static
address 172.26.56.2/26
gateway 172.26.56.1
dns-nameservers 172.26.56.1
dns-search it2XX.int
EOF
ifup mgmt
Mirror-Port konfigurieren (SPAN)
port23 dient als Mirror-Ausgang — dort kann ein IDS oder Wireshark angeschlossen werden:
ovs-vsctl add-port sw0 port23
ovs-vsctl -- --id=@p get port port23 \
-- --id=@m create Mirror name=mirror0 \
select-all=true \
select-vlan=21,22,23 \
output-port=@p \
-- set Bridge sw0 mirrors=@m
Kontrolle
ovs-vsctl list Mirror
Erwartete Ausgabe (gekürzt):
- name: mirror0
- select-vlan: [1,21,22,23]
- output-port: port23
Nutzung
- An port23 wird ein IDS oder ein Analyse-System (z. B. Wireshark/tcpdump) angeschlossen
- Dort ist der gesamte Traffic der VLANs 21, 22 und 23 sichtbar
SNMPv3 konfigurieren
- Datei /etc/snmp/snmpd.conf anpassen
########################################################################### # SECTION: System Information ########################################################################### sysLocation Lab sysContact admin <admin@lab.int> sysServices 72 ########################################################################### # SECTION: Agent Operating Mode ########################################################################### master agentx agentaddress udp:161,udp6:161 ########################################################################### # SECTION: Access Control ########################################################################### # View: alles unterhalb der MIB-Wurzel view full included .1 # SNMPv1/v2c deaktiviert - keine rocommunity Einträge # SNMPv3 User createUser ovsuser SHA "123Start$" AES "Passw0rd" rouser ovsuser authPriv -V full includeDir /etc/snmp/snmpd.conf.d HERE
- Restart
systemctl restart snmpd
- Test der SNMPv3-Abfrage
snmpwalk -v3 -u ovsuser -l authPriv -a SHA -A 123Start$ -x AES -X Passw0rd localhost
Wichtige Befehle
OVS-Diagnose
Zeigt die komplette OVS-Bridge-Konfiguration (Bridges, Ports, VLAN-Tags).
- ovs-vsctl show
Listet alle Ports, die an der Bridge sw0 hängen.
- ovs-vsctl list-ports sw0
Zeigt Details zum Port port2 (inklusive VLAN-Tag).
- ovs-vsctl list interface port2
Zeigt, welche VLANs auf dem Trunk-Port port1 erlaubt sind.
- ovs-vsctl get port port1 trunks
Zeigt den Zustand der Datenebene (DPIF-Interfaces, OpenFlow).
- ovs-dpctl show
Zeigt die Forwarding Database (FDB), ähnlich wie show mac address-table auf Cisco.
- ovs-appctl fdb/show sw0
Zeigt vorhandene SPAN/Mirror-Konfigurationen.
- ovs-appctl mirror/list sw0
VLAN-Konfiguration ändern
Setzt port2 als Access-Port im VLAN 10 (untagged).
- ovs-vsctl set port port2 tag=10
Setzt port3 als Trunk-Port für VLAN 10, 20 und 30 (getagged).
- ovs-vsctl set port port3 trunks=10,20,30
Setzt port3 als Trunk-Port, VLAN 10 untagged (native), VLAN 20 und 30 getagged.
- ovs-vsctl set port port3 tag=10 trunks=20,30
Entfernt VLAN-Zuweisung von port2 bzw. VLAN 20 von port3.
- ovs-vsctl remove port port2 tag
- ovs-vsctl remove port port3 trunks 20
Ergebnis
- port1 = Trunk (VLAN 1 native untagged, VLAN 21/22/23 getaggt)
- port2–port22 = Access-Ports (je VLAN, untagged) — 14 für VMs, 2 Reserve
- port23 = Mirror/SPAN-Ausgang (außerhalb OVS)
- port24 = NAT-Konsolen-Port, DHCP (außerhalb OVS, SSH Port 2222)
- mgmt = Management-Port im VLAN 1 mit IP 172.26.56.2/26
- SNMPv3 = Überwachung aller Interfaces möglich
Nächste Schritte
- Weitere VLANs hinzufügen
- Layer-3 Routing mit OVS oder FRRouting ergänzen
- VXLAN/EVPN mit OVN erproben