Open Vswitch Projekt: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(39 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 4: Zeile 4:
 
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 (eth0–eth17)
+
* 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 14: Zeile 14:
 
== Voraussetzungen ==
 
== Voraussetzungen ==
 
* Debian 13
 
* Debian 13
* Linux-VM mit ≥ 18 Netzwerkkarten (eth0–eth17)
+
* 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>
 
<pre>
 
apt update
 
apt update
apt install openvswitch-switch snmpd network-manager
+
apt install openvswitch-switch snmpd snmp
 
</pre>
 
</pre>
  
NetworkManager als Standard-Renderer aktivieren:
+
== 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>
 
<pre>
systemctl enable --now NetworkManager
+
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>
 
</pre>
  
 
+
=== Kontrolle ===
 
+
<pre>
=== udev-Regel in der VM anlegen ===
+
cat /etc/udev/rules.d/10-ovs-nics.rules
Die Ausgabe die wir auf dem Hosts System produziert haben, in der VM unter '''/etc/udev/rules.d/10-ovs-nics.rules''' speichern.
+
</pre>
  
 
=== Änderungen aktivieren ===
 
=== Änderungen aktivieren ===
Zeile 40: Zeile 50:
 
</pre>
 
</pre>
  
=== Kontrolle nach dem 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:
 
<pre>
 
<pre>
ip link show
+
cat > /etc/network/interfaces << 'EOF'
</pre>
+
source /etc/network/interfaces.d/*
Erwartete Ausgabe: Interfaces '''eth1''' bis '''eth18''' sind sichtbar.
+
 
 +
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
  
== Interfaces per nmcli hochziehen ==
+
auto port24
 +
iface port24 inet dhcp
  
Die physischen Interfaces werden ausschließlich per '''nmcli''' aktiviert — kein Editieren von Konfigurationsdateien nötig. 
+
EOF
OVS übernimmt danach die komplette VLAN- und Bridge-Konfiguration.
 
  
Für jedes Interface (eth0–eth16) ein Connection-Profil anlegen und aktivieren:
+
</pre>
 +
 
 +
=== Änderungen aktivieren ===
 
<pre>
 
<pre>
for i in $(seq 0 16); do
+
udevadm control --reload-rules
    nmcli con add type ethernet ifname eth$i con-name eth$i \
+
reboot
        ipv4.method disabled \
 
        ipv6.method ignore \
 
        connection.autoconnect yes
 
    nmcli con up eth$i
 
done
 
 
</pre>
 
</pre>
  
Separater Uplink eth17 mit DHCP:
+
=== Kontrolle nach dem Reboot ===
 
<pre>
 
<pre>
nmcli con add type ethernet ifname eth17 con-name eth17 \
+
ip link show
    ipv4.method auto \
 
    connection.autoconnect yes
 
nmcli con up eth17
 
 
</pre>
 
</pre>
 +
Erwartete Ausgabe: Interfaces '''port1''' bis '''port18''' sind sichtbar.
  
 
== OVS-Bridge anlegen ==
 
== OVS-Bridge anlegen ==
Zeile 77: Zeile 155:
 
== Trunk-Port konfigurieren (z. B. Richtung OPNsense/Router) ==
 
== Trunk-Port konfigurieren (z. B. Richtung OPNsense/Router) ==
 
<pre>
 
<pre>
ovs-vsctl add-port sw0 eth0 tag=1 trunks=21,22,23 vlan_mode=native-untagged
+
ovs-vsctl add-port sw0 port1 tag=1 trunks=21,22,23 vlan_mode=native-untagged
 
</pre>
 
</pre>
  
 
== Access-Ports konfigurieren ==
 
== 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>
 
<pre>
ovs-vsctl add-port sw0 eth1 tag=1
+
ovs-vsctl add-port sw0 port2 tag=21
ovs-vsctl add-port sw0 eth2 tag=21
+
ovs-vsctl add-port sw0 port3 tag=21
ovs-vsctl add-port sw0 eth3 tag=22
+
ovs-vsctl add-port sw0 port4 tag=21
ovs-vsctl add-port sw0 eth4 tag=23
+
ovs-vsctl add-port sw0 port5 tag=21
ovs-vsctl add-port sw0 eth5 tag=1
+
ovs-vsctl add-port sw0 port6 tag=21
ovs-vsctl add-port sw0 eth6 tag=1
+
ovs-vsctl add-port sw0 port7 tag=21
ovs-vsctl add-port sw0 eth7 tag=1
+
ovs-vsctl add-port sw0 port8 tag=21
ovs-vsctl add-port sw0 eth8 tag=1
+
ovs-vsctl add-port sw0 port9 tag=21
ovs-vsctl add-port sw0 eth9  tag=1
+
ovs-vsctl add-port sw0 port10 tag=21
ovs-vsctl add-port sw0 eth10 tag=1
+
ovs-vsctl add-port sw0 port11 tag=22
ovs-vsctl add-port sw0 eth11 tag=1
+
ovs-vsctl add-port sw0 port12 tag=22
ovs-vsctl add-port sw0 eth12 tag=1
+
ovs-vsctl add-port sw0 port13 tag=22
ovs-vsctl add-port sw0 eth13 tag=1
+
ovs-vsctl add-port sw0 port14 tag=22
ovs-vsctl add-port sw0 eth14 tag=1
+
ovs-vsctl add-port sw0 port15 tag=22
ovs-vsctl add-port sw0 eth15 tag=1
+
ovs-vsctl add-port sw0 port16 tag=23
ovs-vsctl add-port sw0 eth16 tag=1
+
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>
 
</pre>
  
== Management-Interface im VLAN 1 ==
+
== Interface der VLANs anlegen ==
  
Internen OVS-Port für die Management-IP anlegen:
 
 
<pre>
 
<pre>
ovs-vsctl add-port sw0 mgmt tag=1 -- set interface mgmt type=internal
+
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>
 
</pre>
  
Management-IP per nmcli setzen:
+
Management-IP per '''/etc/network/interfaces''' setzen:
 
<pre>
 
<pre>
nmcli con add type ethernet ifname mgmt con-name mgmt \
+
cat >> /etc/network/interfaces << 'EOF'
     ipv4.method manual \
+
 
    ipv4.addresses 172.26.56.2/26 \
+
auto mgmt
     ipv4.gateway 172.26.56.1 \
+
iface mgmt inet static
     connection.autoconnect yes
+
     address 172.26.56.2/26
nmcli con up mgmt
+
     gateway 172.26.56.1
 +
    dns-nameservers 172.26.56.1
 +
     dns-search it2XX.int
 +
EOF
 +
 
 +
ifup mgmt
 
</pre>
 
</pre>
  
 
== Mirror-Port konfigurieren (SPAN) ==
 
== 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
    select-vlan=1,21,22,23 \
+
ovs-vsctl -- --id=@p get port port23 \
    output-port=eth17 \
+
          -- --id=@m create Mirror name=mirror0 \
    -- set Bridge sw0 mirrors=@m
+
          select-all=true \
 +
          select-vlan=21,22,23 \
 +
          output-port=@p \
 +
          -- set Bridge sw0 mirrors=@m
 
</pre>
 
</pre>
  
Zeile 133: Zeile 247:
 
* name: mirror0
 
* name: mirror0
 
* select-vlan: [1,21,22,23]
 
* select-vlan: [1,21,22,23]
* output-port: eth17
+
* output-port: port23
  
 
=== Nutzung ===
 
=== Nutzung ===
* An '''eth17''' wird ein IDS oder ein Analyse-System (z. B. Wireshark/tcpdump) angeschlossen
+
* An '''port23''' wird ein IDS oder ein Analyse-System (z. B. Wireshark/tcpdump) angeschlossen
* Dort ist der gesamte Traffic der VLANs 1, 21, 22 und 23 sichtbar
+
* 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>
 
<pre>
createUser ovsuser SHA "MeinGeheimesPasswort" AES "NochGeheimer"
+
###########################################################################
rouser ovsuser authPriv
+
# SECTION: System Information
</pre>
+
###########################################################################
 +
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
  
SNMP-Dienst neu starten:
+
includeDir /etc/snmp/snmpd.conf.d
<pre>
+
HERE
systemctl restart snmpd
 
 
</pre>
 
</pre>
  
Test der SNMPv3-Abfrage:
+
;Restart
 +
systemctl restart snmpd
 +
;Test der SNMPv3-Abfrage:
 
<pre>
 
<pre>
snmpwalk -v3 -u ovsuser -l authPriv -a SHA -A MeinGeheimesPasswort -x AES -X NochGeheimer localhost ifDescr
+
snmpwalk -v3 -u ovsuser -l authPriv -a SHA -A 123Start$ -x AES -X Passw0rd localhost
 
</pre>
 
</pre>
  
Zeile 166: Zeile 303:
 
* '''ovs-vsctl list-ports sw0'''
 
* '''ovs-vsctl list-ports sw0'''
  
Zeigt Details zum Port ''eth1'' (inklusive VLAN-Tag).
+
Zeigt Details zum Port ''port2'' (inklusive VLAN-Tag).
* '''ovs-vsctl list interface eth1'''
+
* '''ovs-vsctl list interface port2'''
  
Zeigt, welche VLANs auf dem Trunk-Port ''eth0'' erlaubt sind.
+
Zeigt, welche VLANs auf dem Trunk-Port ''port1'' erlaubt sind.
* '''ovs-vsctl get port eth0 trunks'''
+
* '''ovs-vsctl get port port1 trunks'''
  
 
Zeigt den Zustand der Datenebene (DPIF-Interfaces, OpenFlow).
 
Zeigt den Zustand der Datenebene (DPIF-Interfaces, OpenFlow).
Zeile 180: Zeile 317:
 
Zeigt vorhandene SPAN/Mirror-Konfigurationen.
 
Zeigt vorhandene SPAN/Mirror-Konfigurationen.
 
* '''ovs-appctl mirror/list sw0'''
 
* '''ovs-appctl mirror/list sw0'''
 
=== nmcli-Diagnose ===
 
 
Zeigt alle aktiven Verbindungen.
 
* '''nmcli con show --active'''
 
 
Zeigt den Status eines bestimmten Interface.
 
* '''nmcli dev status'''
 
  
 
=== VLAN-Konfiguration ändern ===
 
=== VLAN-Konfiguration ändern ===
  
Setzt ''eth1'' als Access-Port im VLAN 10 (untagged).
+
Setzt ''port2'' als Access-Port im VLAN 10 (untagged).
* '''ovs-vsctl set port eth1 tag=10'''
+
* '''ovs-vsctl set port port2 tag=10'''
  
Setzt ''eth2'' als Trunk-Port für VLAN 10, 20 und 30 (getagged).
+
Setzt ''port3'' als Trunk-Port für VLAN 10, 20 und 30 (getagged).
* '''ovs-vsctl set port eth2 trunks=10,20,30'''
+
* '''ovs-vsctl set port port3 trunks=10,20,30'''
  
Setzt ''eth2'' als Trunk-Port, VLAN 10 untagged (native), VLAN 20 und 30 getagged.
+
Setzt ''port3'' als Trunk-Port, VLAN 10 untagged (native), VLAN 20 und 30 getagged.
* '''ovs-vsctl set port eth2 tag=10 trunks=20,30'''
+
* '''ovs-vsctl set port port3 tag=10 trunks=20,30'''
  
Entfernt VLAN-Zuweisung von ''eth1'' bzw. VLAN 20 von ''eth2''.
+
Entfernt VLAN-Zuweisung von ''port2'' bzw. VLAN 20 von ''port3''.
* '''ovs-vsctl remove port eth1 tag'''
+
* '''ovs-vsctl remove port port2 tag'''
* '''ovs-vsctl remove port eth2 trunks 20'''
+
* '''ovs-vsctl remove port port3 trunks 20'''
  
 
== Ergebnis ==
 
== Ergebnis ==
* '''eth0''' = Trunk (VLAN 1 native untagged, VLAN 21/22/23 getaggt)
+
* '''port1''' = Trunk (VLAN 1 native untagged, VLAN 21/22/23 getaggt)
* '''eth1–eth16''' = Access-Ports (je VLAN, untagged) — 14 für VMs, 2 Reserve
+
* '''port2–port22''' = Access-Ports (je VLAN, untagged) — 14 für VMs, 2 Reserve
* '''eth17''' = Mirror/SPAN-Ausgang + DHCP-Uplink
+
* '''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
* Kein Editieren von Konfigurationsdateien nötig
 
  
 
== Nächste Schritte ==
 
== Nächste Schritte ==

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