VLAN mit Linux und Cisco Nexus: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
 
(35 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
 
=== Zielbeschreibung ===
 
=== Zielbeschreibung ===
 
* Der Cisco-Port '''Ethernet1/1''' ist als '''802.1Q-Trunk''' konfiguriert.
 
* Der Cisco-Port '''Ethernet1/1''' ist als '''802.1Q-Trunk''' konfiguriert.
* Der Linux-Rechner verwendet das Interface '''enp0s10'''.
+
* Der Linux-Rechner verwendet das Interface '''enp0s8'''.
* Zwei VLANs werden getaggt übertragen:
+
* Drei VLANs werden getaggt übertragen:
** VLAN 22 → '''172.17.113.1/24'''
+
* Ethernet1/2 und Ethernet1/3 → LAN
** VLAN 23 → '''172.18.113.1/24'''
+
* Ethernet1/4 und Ethernet1/5 → SERVER
 +
* Ethernet1/6 und Ethernet1/7 → MGMT
 +
** VLAN 24 → '''172.18.2xx.1/24'''
 +
** VLAN 22 → '''172.17.2xx.1/24'''
 +
** VLAN 23 → '''172.16.2xx.1/24'''
  
 
== Plan ==
 
== Plan ==
Zeile 19: Zeile 23:
 
=== /etc/network/interfaces ===
 
=== /etc/network/interfaces ===
 
<pre>
 
<pre>
auto lo
+
#OHNE IP
iface lo inet loopback
+
auto enp0s8
 +
iface enp0s8 inet manual
  
auto enp0s10
+
#LAN
iface enp0s10 inet manual
+
auto enp0s8.22
 +
iface enp0s8.22 inet static
 +
address 172.17.2xx.1/24
 +
vlan-raw-device enp0s8
  
auto enp0s10.22
+
#SERVER
iface enp0s10.22 inet static
+
auto enp0s8.23
  address 172.16.113.1
+
iface enp0s8.23 inet static
  netmask 255.255.255.0
+
address 172.16.2xx.1/24
  vlan-raw-device enp0s10
+
vlan-raw-device enp0s8
 +
 
 +
#MGMT
 +
auto enp0s8.24
 +
iface enp0s8.24 inet static
 +
address 172.18.2xx.1/24
 +
vlan-raw-device enp0s8
 +
root@fw:~#
  
auto enp0s10.23
 
iface enp0s10.23 inet static
 
  address 172.18.113.1
 
  netmask 255.255.255.0
 
  vlan-raw-device enp0s10
 
 
</pre>
 
</pre>
 +
 +
==Zum Cisco==
 +
*ssh localhost -p 3022
 +
oder im Notfall
 +
*nc localhost 2023
 +
;Logindaten
 +
*user: admin
 +
*pass: admin
 +
  
 
===VLAN anlegen===
 
===VLAN anlegen===
 +
configure terminal
 
  vlan 22
 
  vlan 22
 +
name LAN
 +
vlan 23
 
  name SERVER
 
  name SERVER
  vlan 23
+
  vlan 24
 
  name MGMT
 
  name MGMT
 
+
end
 +
copy running-config startup-config
  
 
=== Cisco-Konfiguration für Ethernet1/1 ===
 
=== Cisco-Konfiguration für Ethernet1/1 ===
<pre>
+
configure terminal
 +
<pre>
 
interface Ethernet1/1
 
interface Ethernet1/1
 
   description Trunk zu Linux-Host
 
   description Trunk zu Linux-Host
 
   switchport mode trunk
 
   switchport mode trunk
   switchport trunk allowed vlan 22,23
+
   switchport trunk allowed vlan 22,23,24
 
   spanning-tree port type edge trunk
 
   spanning-tree port type edge trunk
 
</pre>
 
</pre>
  
 
=== Cisco-Konfiguration für Access-Ports ===
 
=== Cisco-Konfiguration für Access-Ports ===
;Ethernet1/2 und Ethernet1/3 → VLAN 22 (SERVER)
+
;Ethernet1/2 und Ethernet1/3 → VLAN 22 (LAN)
 
<pre>
 
<pre>
interface Ethernet1/2
+
interface Ethernet1/2-3
  description VLAN 22 SERVER
+
   description VLAN 22 LAN
  switchport mode access
 
  switchport access vlan 22
 
  spanning-tree port type edge
 
 
 
interface Ethernet1/3
 
   description VLAN 22 SERVER
 
 
   switchport mode access
 
   switchport mode access
 
   switchport access vlan 22
 
   switchport access vlan 22
Zeile 70: Zeile 88:
 
</pre>
 
</pre>
  
;Ethernet1/4 und Ethernet1/5 → VLAN 23 (MGMT)
+
;Ethernet1/4 und Ethernet1/5 → VLAN 23 (SERVER)
 
<pre>
 
<pre>
interface Ethernet1/4
+
interface Ethernet1/4-5
   description VLAN 23 MGMT
+
   description VLAN 23 SERVER
 
   switchport mode access
 
   switchport mode access
 
   switchport access vlan 23
 
   switchport access vlan 23
 
   spanning-tree port type edge
 
   spanning-tree port type edge
 +
</pre>
  
interface Ethernet1/5
+
;Ethernet1/6 und Ethernet1/7 → VLAN 24 (MGMT)
   description VLAN 23 MGMT
+
<pre>
 +
interface Ethernet1/6-7
 +
   description VLAN 24 MGMT
 
   switchport mode access
 
   switchport mode access
   switchport access vlan 23
+
   switchport access vlan 24
 
   spanning-tree port type edge
 
   spanning-tree port type edge
 
</pre>
 
</pre>
 +
 +
end
 +
copy running-conf startup-conf
 +
 +
==IP im MGMT NETZ Vergeben==
 +
configure terminal
 +
interface vlan 24
 +
description MGMT-IP
 +
ip address 172.18.213.11/24
 +
no shutdown
 +
end
 +
 +
==Gateway und Nameserver einstellen==
 +
configure terminal
 +
ip route 0.0.0.0/0 172.18.2xx.1
 +
ip name-server 10.88.2xx.21
 +
end
 +
copy running-configure startup-configure
 +
 +
==Checken==
 +
show running-config
  
 
=== Aktivierung der Konfiguration ===
 
=== Aktivierung der Konfiguration ===
Zeile 90: Zeile 132:
 
*ip addr show
 
*ip addr show
 
* Sicherstellen, dass die IP-Adressen korrekt zugewiesen wurden und die Kommunikation innerhalb der VLANs funktioniert.
 
* Sicherstellen, dass die IP-Adressen korrekt zugewiesen wurden und die Kommunikation innerhalb der VLANs funktioniert.
 +
== TODO Anpassungen ==
 +
*Firewall
 +
*DHCP Server
 +
*Sonst nochwas?

Aktuelle Version vom 31. Juli 2025, 09:13 Uhr

Zielbeschreibung

  • Der Cisco-Port Ethernet1/1 ist als 802.1Q-Trunk konfiguriert.
  • Der Linux-Rechner verwendet das Interface enp0s8.
  • Drei VLANs werden getaggt übertragen:
  • Ethernet1/2 und Ethernet1/3 → LAN
  • Ethernet1/4 und Ethernet1/5 → SERVER
  • Ethernet1/6 und Ethernet1/7 → MGMT
    • VLAN 24 → 172.18.2xx.1/24
    • VLAN 22 → 172.17.2xx.1/24
    • VLAN 23 → 172.16.2xx.1/24

Plan


Voraussetzungen auf Debian/Linux

VLAN-Paket installieren
  • apt install vlan
VLAN-Modul laden
  • sudo modprobe 8021q
Modul beim Booten automatisch laden
  • echo 8021q | sudo tee -a /etc/modules

/etc/network/interfaces

#OHNE IP 
auto enp0s8
iface enp0s8 inet manual

#LAN
auto enp0s8.22
 iface enp0s8.22 inet static
 address 172.17.2xx.1/24
 vlan-raw-device enp0s8 

#SERVER
auto enp0s8.23
 iface enp0s8.23 inet static
 address 172.16.2xx.1/24
 vlan-raw-device enp0s8 

#MGMT
auto enp0s8.24
 iface enp0s8.24 inet static
 address 172.18.2xx.1/24
 vlan-raw-device enp0s8 
root@fw:~# 

Zum Cisco

  • ssh localhost -p 3022

oder im Notfall

  • nc localhost 2023
Logindaten
  • user: admin
  • pass: admin


VLAN anlegen

configure terminal
vlan 22
name LAN
vlan 23 
name SERVER
vlan 24
name MGMT
end
copy running-config startup-config

Cisco-Konfiguration für Ethernet1/1

configure terminal
interface Ethernet1/1
  description Trunk zu Linux-Host
  switchport mode trunk
  switchport trunk allowed vlan 22,23,24
  spanning-tree port type edge trunk

Cisco-Konfiguration für Access-Ports

Ethernet1/2 und Ethernet1/3 → VLAN 22 (LAN)
interface Ethernet1/2-3
  description VLAN 22 LAN
  switchport mode access
  switchport access vlan 22
  spanning-tree port type edge
Ethernet1/4 und Ethernet1/5 → VLAN 23 (SERVER)
interface Ethernet1/4-5
  description VLAN 23 SERVER
  switchport mode access
  switchport access vlan 23
  spanning-tree port type edge
Ethernet1/6 und Ethernet1/7 → VLAN 24 (MGMT)
interface Ethernet1/6-7
  description VLAN 24 MGMT
  switchport mode access
  switchport access vlan 24
  spanning-tree port type edge
end
copy running-conf startup-conf

IP im MGMT NETZ Vergeben

configure terminal
interface vlan 24
description MGMT-IP
ip address 172.18.213.11/24
no shutdown 
end

Gateway und Nameserver einstellen

configure terminal
ip route 0.0.0.0/0 172.18.2xx.1 
ip name-server 10.88.2xx.21
end
copy running-configure startup-configure

Checken

show running-config

Aktivierung der Konfiguration

Nach den obigen Anpassungen auf dem Linux-System die Netzwerkschnittstellen neu starten:

  • sudo systemctl restart networking
  • ip addr show
  • Sicherstellen, dass die IP-Adressen korrekt zugewiesen wurden und die Kommunikation innerhalb der VLANs funktioniert.

TODO Anpassungen

  • Firewall
  • DHCP Server
  • Sonst nochwas?