L10: VLAN och VTP


I större switchade nätverk kan hanteringen av VLAN snabbt bli både tidskrävande och felkänslig om varje VLAN måste skapas och underhållas manuellt på varje enskild switch. För att förenkla denna administration används VTP (VLAN Trunking Protocol).

VTP är ett Cisco-proprietärt Layer-2-protokoll som används för att distribuera och synkronisera VLAN-information mellan switchar inom samma nätverk. Genom att placera switcharna i samma VTP-domän säkerställs att alla enheter delar en gemensam och konsekvent VLAN-databas. När ett VLAN skapas, ändras eller tas bort på en switch som kör VTP i serverläge, sprids denna information automatiskt till övriga switchar i domänen via trunklänkar.

Det är viktigt att skilja på VLAN-administration och VLAN-trafik. VTP ansvarar enbart för att hantera vilka VLAN som existerar i nätverket, men styr inte hur trafiken faktiskt transporteras. Protokollet filtrerar inte VLAN. Vilka VLAN som tillåts på en specifik trunklänk avgörs istället av trunkinställningar, exempelvis med kommandot switchport trunk allowed vlan.

VTP i denna laboration

VTP använder en klassisk server- och klientmodell, där en central VTP-server ansvarar för VLAN-databasen och övriga switchar fungerar som klienter. För att VTP ska fungera korrekt krävs att samtliga switchar använder samma VTP-domän, samma version och – om konfigurerat – samma VTP-lösenord. Detta bidrar till en mer kontrollerad och förutsägbar VLAN-hantering.

I denna laboration används samtidigt VTP för central administration av VLAN och manuell VLAN-filtrering på trunkar. På detta sätt kan nätverket delas upp i separata segment, exempelvis vänster-, höger- och mittendel, där endast relevanta VLAN tillåts på respektive trunk.

Topologi

Konfigurationer

Kommandot spanning-tree mode pvst aktiverar PVST (Per-VLAN Spanning Tree), vilket innebär att varje VLAN har sin egen Spanning Tree-instans. Detta gör det möjligt att hantera loopskydd och root-bridge per VLAN.

Kommandot spanning-tree vlan 1,10,20,30,50,60,70,99,999 root primary anger att switchen ska bli root bridge för de listade VLAN:en. Om det redan finns en root sänker switchen automatiskt sitt bridge-ID för att ta rollen som primär root.

Kort sagt säkerställs att denna switch blir den centrala referenspunkten för Spanning Tree i angivna VLAN.

  • SW-VTP(config)# no ip domain-lookup
  • SW-VTP(config)# service password-encryption
  • ! VTP konfigurering
  • SW-VTP(config)# vtp version 2
  • SW-VTP(config)# vtp domain diginto.se
  • SW-VTP(config)# vtp password LetmeP@55
  • SW-VTP(config)# vtp mode server
  • ! Skapa VLANs
  • SW-VTP(config)# vlan 10
  • SW-VTP(config-vlan)# name IT
  • SW-VTP(config-vlan)# vlan 20
  • SW-VTP(config-vlan)# name HR
  • SW-VTP(config-vlan)# vlan 30
  • SW-VTP(config-vlan)# name ADM
  • SW-VTP(config-vlan)# vlan 50
  • SW-VTP(config-vlan)# name Development
  • SW-VTP(config-vlan)# vlan 60
  • SW-VTP(config-vlan)# name Design
  • SW-VTP(config-vlan)# vlan 70
  • SW-VTP(config-vlan)# name Production
  • SW-VTP(config-vlan)# vlan 99
  • SW-VTP(config-vlan)# name Management
  • SW-VTP(config-vlan)# vlan 100
  • SW-VTP(config-vlan)# name Consults
  • SW-VTP(config-vlan)# vlan 110
  • SW-VTP(config-vlan)# name Partners
  • SW-VTP(config-vlan)# vlan 999
  • SW-VTP(config-vlan)# name Native
  • SW-VTP(config-vlan)# exit
  • ! Aktiverar PVST och anger Root bridge switchen
  • SW-VTP(config)# spanning-tree mode pvst
  • SW-VTP(config)# spanning-tree vlan 1,10,20,30,50,60,70,99,999 root primary
  • ! Trunk konfigureringar
  • SW-VTP(config)# interface g0/1
  • SW-VTP(config-if)# description länk till SW-L1
  • SW-VTP(config-if)# switchport mode trunk
  • SW-VTP(config-if)# switchport trunk native vlan 999
  • SW-VTP(config-if)# switchport trunk allowed vlan 10,20,30,99,999
  • SW-VTP(config-if)# exit
  • SW-VTP(config)# interface g0/2
  • SW-VTP(config-if)# description länk till SW-M1
  • SW-VTP(config-if)# switchport mode trunk
  • SW-VTP(config-if)# switchport trunk native vlan 999
  • SW-VTP(config-if)# switchport trunk allowed vlan 99,100,110,999
  • SW-VTP(config-if)# exit
  • SW-VTP(config)# interface fa0/24
  • SW-VTP(config-if)# description länk till SW-R1
  • SW-VTP(config-if)# switchport mode trunk
  • SW-VTP(config-if)# switchport trunk native vlan 999
  • SW-VTP(config-if)# switchport trunk allowed vlan 50,60,70,99,999
  • SW-VTP(config-if)# exit
  • SW-VTP(config)# end
  • SW-VTP# write memory

SW-L1 konfiguration

  • SW-L1(config)# no ip domain-lookup
  • SW-L1(config)# service password-encryption
  • ! VTP konfiguration
  • SW-L1(config)# vtp version 2
  • SW-L1(config)# vtp domain diginto.se
  • SW-L1(config)# vtp password LetmeP@55
  • SW-L1(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 10, 20, 30, 99, 999
  • SW-L1(config)# interface range g0/1-2
  • SW-L1(config-if)# switchport mode trunk
  • SW-L1(config-if)# switchport trunk native vlan 999
  • SW-L1(config-if)# switchport trunk allowed vlan 10,20,30,99,999
  • SW-L1(config-if)# exit
  • SW-L1(config)# end
  • SW-L1# write memory

SW-L2 konfiguration

  • SW-L2(config)# no ip domain-lookup
  • SW-L2(config)# service password-encryption
  • ! VTP konfiguration
  • SW-L2(config)# vtp version 2
  • SW-L2(config)# vtp domain diginto.se
  • SW-L2(config)# vtp password LetmeP@55
  • SW-L2(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 10, 20, 30, 99, 999
  • SW-L2(config)# interface range g0/1-2
  • SW-L2(config-if-range)# switchport mode trunk
  • SW-L2(config-if-range)# switchport trunk native vlan 999
  • SW-L2(config-if-range)# switchport trunk allowed vlan 10,20,30,99,999
  • SW-L2(config-if-range)# exit
  • SW-L2(config)# end
  • SW-L2# write memory
  •  

Kommandot interface range fa0/1-21 väljer flera accessportar samtidigt för gemensam konfiguration.

Kommandot spanning-tree portfast gör att portarna går direkt till forwarding-läge, vilket är lämpligt för portar där endast slutenheter (t.ex. datorer) är anslutna.

Kommandot spanning-tree bpduguard enable skyddar nätverket genom att stänga porten automatiskt om en BPDU tas emot, vilket förhindrar att en switch av misstag kopplas in på en accessport.

  • SW-L3(config)# no ip domain-lookup
  • SW-L3(config)# service password-encryption
  • ! VTP konfiguration
  • SW-L3(config)# vtp version 2
  • SW-L3(config)# vtp domain diginto.se
  • SW-L3(config)# vtp password LetmeP@55
  • SW-L3(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 10, 20, 30, 99, 999
  • SW-L3(config)# interface g0/2
  • SW-L3(config-if)# description länk till SW-L2
  • SW-L3(config-if)# switchport mode trunk
  • SW-L3(config-if)# switchport trunk native vlan 999
  • SW-L3(config-if)# switchport trunk allowed vlan 10,20,30,99,999
  • SW-L3(config-if)# exit
  • ! Access port konfiguration VLAN 10
  • SW-L3(config)# interface range fa0/1-7
  • SW-L3(config-if-range)# switchport mode access
  • SW-L3(config-if-range)# switchport access vlan 10
  • SW-L3(config-if-range)# exit
  • ! Access port konfiguration VLAN 20
  • SW-L3(config)# interface range fa0/8-14
  • SW-L3(config-if-range)# switchport mode access
  • SW-L3(config-if-range)# switchport access vlan 20
  • SW-L3(config-if-range)# exit
  • ! Access port konfiguration VLAN 30
  • SW-L3(config)# interface range fa0/15-21
  • SW-L3(config-if-range)# switchport mode access
  • SW-L3(config-if-range)# switchport access vlan 30
  • SW-L3(config-if-range)# exit
  • ! Snabbare trafikhantering
  • SW-L3(config)# interface range fa0/1-21
  • SW-L3(config-if-range)# spanning-tree portfast
  • SW-L3(config-if-range)# spanning-tree bpduguard enable
  • SW-L3(config-if-range)# exit
  • SW-L3(config)# end
  • SW-L3# write
  • SW-M1(config)# no ip domain-lookup
  • SW-M1(config)# service password-encryption
  • ! VTP konfiguration
  • SW-M1(config)# vtp version 2
  • SW-M1(config)# vtp domain diginto.se
  • SW-M1(config)# vtp password LetmeP@55
  • SW-M1(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 99, 100, 110, 999
  • SW-M1(config)# interface fa0/24
  • SW-M1(config-if)# description länk till SW-M1
  • SW-M1(config-if)# switchport mode trunk
  • SW-M1(config-if)# switchport trunk native vlan 999
  • SW-M1(config-if)# switchport trunk allowed vlan 99,100,110,999
  • SW-M1(config-if)# exit
  • ! Downlink till SW-M2
  • SW-M1(config)# interface fa0/23
  • SW-M1(config-if)# description länk till SW-M2
  • SW-M1(config-if)# switchport mode trunk
  • SW-M1(config-if)# switchport trunk native vlan 999
  • SW-M1(config-if)# switchport trunk allowed vlan 99,100,999
  • SW-M1(config-if)# exit
  • ! Downlink till SW-M3
  • SW-M1(config-if)# interface fa0/22
  • SW-M1(config-if)# description länk till SW-M3
  • SW-M1(config-if)# switchport mode trunk
  • SW-M1(config-if)# switchport trunk native vlan 999
  • SW-M1(config-if)# switchport trunk allowed vlan 99,110,999
  • SW-M1(config-if)# exit
  • SW-M1(config)# end
  • SW-M1# write memory
  • SW-M2(config)# no ip domain-lookup
  • SW-M2(config)# service password-encryption
  • ! VTP konfiguration
  • SW-M2(config)# vtp version 2
  • SW-M2(config)# vtp domain diginto.se
  • SW-M2(config)# vtp password LetmeP@55
  • SW-M2(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 99, 100, 999
  • SW-M2(config)# interface fa0/24
  • SW-M2(config-if)# description länk till SW-M1
  • SW-M2(config-if)# switchport mode trunk
  • SW-M2(config-if)# switchport trunk native vlan 999
  • SW-M2(config-if)# switchport trunk allowed vlan 99,100,999
  • SW-M2(config-if)# exit
  • ! Access port konfiguration VLAN 100
  • SW-M2(config)# interface range fa0/1-15
  • SW-M2(config-if)# switchport mode access
  • SW-M2(config-if)# switchport access vlan 100
  • SW-M2(config-if)# spanning-tree portfast
  • SW-M2(config-if)# spanning-tree bpduguard enable
  • SW-M2(config-if)# exit
  • ! Access port konfiguration VLAN 99
  • SW-M2(config)# interface range fa0/16-23
  • SW-M2(config-if-range)# switchport mode access
  • SW-M2(config-if-range)# switchport access vlan 99
  • SW-M2(config-if-range)# spanning-tree portfast
  • SW-M2(config-if-range)# spanning-tree bpduguard enable
  • SW-M2(config-if-range)# exit
  • SW-M2(config)# end
  • SW-M2# write memory
  • SW-M3(config)# no ip domain-lookup
  • SW-M3(config)# service password-encryption
  • ! VTP konfiguration
  • SW-M3(config)# vtp version 2
  • SW-M3(config)# vtp domain diginto.se
  • SW-M3(config)# vtp password LetmeP@55
  • SW-M3(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 99, 110, och 999
  • SW-M3(config)# interface fa0/24
  • SW-M3(config-if)# description länk till SW-M1
  • SW-M3(config-if)# switchport mode trunk
  • SW-M3(config-if)# switchport trunk native vlan 999
  • SW-M3(config-if)# switchport trunk allowed vlan 99,110,999
  • SW-M3(config-if)# exit
  • ! Access port konfiguration VLAN 110
  • SW-M3(config)# interface range fa0/1-15
  • SW-M3(config-if)# switchport mode access
  • SW-M3(config-if)# switchport access vlan 110
  • SW-M3(config-if)# spanning-tree portfast
  • SW-M3(config-if)# spanning-tree bpduguard enable
  • SW-M3(config-if)# exit
  • ! Access port konfiguration VLAN 99
  • SW-M3(config)# interface range fa0/16-23
  • SW-M3(config-if)# switchport mode access
  • SW-M3(config-if)# switchport access vlan 99
  • SW-M3(config-if)# spanning-tree portfast
  • SW-M3(config-if)# spanning-tree bpduguard enable
  • SW-M3(config-if)# exit
  • SW-M3(config)# end
  • SW-M3# write memory

SW-R1 konfiguration

  • SW-R1(config)# no ip domain-lookup
  • SW-R1(config)# service password-encryption
  • ! VTP konfiguration
  • SW-R1(config)# vtp version 2
  • SW-R1(config)# vtp domain diginto.se
  • SW-R1(config)# vtp password LetmeP@55
  • SW-R1(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 50,60,70,99,999
  • SW-R1(config)# interface range g0/1-2
  • SW-R1(config-if)# switchport mode trunk
  • SW-R1(config-if)# switchport trunk native vlan 999
  • SW-R1(config-if)# switchport trunk allowed vlan 50,60,70,99,999
  • SW-R1(config-if)# exit
  • SW-R1(config)# end
  • SW-R1# write memory

SW-R2 konfiguration

  • SW-R2(config)# no ip domain-lookup
  • SW-R2(config)# service password-encryption
  • ! VTP konfiguration
  • SW-R2(config)# vtp version 2
  • SW-R2(config)# vtp domain diginto.se
  • SW-R2(config)# vtp password LetmeP@55
  • SW-R2(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 50,60,70,99,999
  • SW-R2(config)# interface range g0/1-2
  • SW-R2(config-if)# switchport mode trunk
  • SW-R2(config-if)# switchport trunk native vlan 999
  • SW-R2(config-if)# switchport trunk allowed vlan 50,60,70,99,999
  • SW-R2(config-if)# exit
  • SW-R2(config)# end
  • SW-R# write memory
  •  

Kommandot spanning-tree portfast gör att portarna går direkt till forwarding-läge, vilket är lämpligt för portar där endast slutenheter (t.ex. datorer) är anslutna.

Kommandot spanning-tree bpduguard enable skyddar nätverket genom att stänga porten automatiskt om en BPDU tas emot, vilket förhindrar att en switch av misstag kopplas in på en accessport.

  • SW-R3(config)# no ip domain-lookup
  • SW-R3(config)# service password-encryption
  • ! VTP konfiguration
  • SW-R3(config)# vtp version 2
  • SW-R3(config)# vtp domain diginto.se
  • SW-R3(config)# vtp password LetmeP@55
  • SW-R3(config)# vtp mode client
  • ! Trunk konfiguration - tillåtna VLAN 50, 60, 70, 99, 999
  • SW-R3(config)# interface g0/1
  • SW-R3(config-if)# description länk till SW-R2
  • SW-R3(config-if)# switchport mode trunk
  • SW-R3(config-if)# switchport trunk native vlan 999
  • SW-R3(config-if)# switchport trunk allowed vlan 50,60,70,99,999
  • SW-R3(config-if)# exit
  • ! Access port konfiguration VLAN 50
  • SW-R3(config)# interface range fa0/1-7
  • SW-R3(config-if-range)# switchport mode access
  • SW-R3(config-if-range)# switchport access vlan 50
  • SW-R3(config-if-range)# exit
  • ! Access port konfiguration VLAN 60
  • SW-R3(config)# interface range fa0/8-14
  • SW-R3(config-if-range)# switchport mode access
  • SW-R3(config-if-range)# switchport access vlan 60
  • SW-R3(config-if-range)# exit
  • ! Access port konfiguration VLAN 70
  • SW-R3(config)# interface range fa0/15-21
  • SW-R3(config-if-range)# switchport mode access
  • SW-R3(config-if-range)# switchport access vlan 70
  • SW-R3(config-if-range)# exit
  • ! Snabbare trafikhantering
  • SW-R3(config)# interface range fa0/1-21
  • SW-R3(config-if-range)# spanning-tree portfast
  • SW-R3(config-if-range)# spanning-tree bpduguard enable
  • SW-R3(config-if-range)# exit
  • SW-R3(config)# end
  • SW-R3# write

Router-on-a-Stick är en metod för inter-VLAN-routing där en enda fysisk routerport används för att routa trafik mellan flera VLAN. Detta uppnås genom att skapa subinterfaces på routern, där varje subinterface kopplas till ett specifikt VLAN med 802.1Q-taggning och tilldelas en IP-adress som fungerar som default gateway för VLAN:et.

Den fysiska länken mellan switch och router konfigureras som trunk, så att flera VLAN kan transporteras över samma kabel.

Router-on-a-Stick används ofta i mindre eller medelstora nätverk där en Layer-3-switch inte finns tillgänglig, men har begränsad prestanda jämfört med routing direkt på en L3-switch.

  • R1(config)# no ip domain-lookup
  • ! Router-on-a-stick - ROAS konfiguration
  • R1(config)# interface fa0/0
  • R1(config-if)# no shutdown
  • R1(config-if)# exit
  • ! Native VLAN 999 (ingen IP)
  • R1(config)# interface fa0/0.999
  • R1(config-subif)# encapsulation dot1Q 999 native
  • R1(config-subif)# no ip address
  • R1(config-subif)# exit
  • ! VLAN 10 – IT
  • R1(config)# interface fa0/0.10
  • R1(config-subif)# encapsulation dot1Q 10
  • R1(config-subif)# ip address 172.24.10.1 255.255.255.224
  • R1(config-subif)# exit
  • ! VLAN 20 – HR
  • R1(config)# interface fa0/0.20
  • R1(config-subif)# encapsulation dot1Q 20
  • R1(config-subif)# ip address 172.24.20.1 255.255.255.224
  • R1(config-subif)# exit
  • ! VLAN 30 – ADM
  • R1(config)# interface fa0/0.30
  • R1(config-subif)# encapsulation dot1Q 30
  • R1(config-subif)# ip address 172.24.30.1 255.255.255.224
  • R1(config-subif)# exit
  • ! VLAN 50 – Development
  • R1(config)# interface fa0/0.50
  • R1(config-subif)# encapsulation dot1Q 50
  • R1(config-subif)# ip address 192.168.50.1 255.255.255.224
  • R1(config-subif)# exit
  • ! VLAN 60 – Design
  • R1(config)# interface fa0/0.60
  • R1(config-subif)# encapsulation dot1Q 60
  • R1(config-subif)# ip address 192.168.60.1 255.255.255.224
  • R1(config-subif)# exit
  • ! VLAN 70 – Production
  • R1(config)# interface fa0/0.70
  • R1(config-subif)# encapsulation dot1Q 70
  • R1(config-subif)# ip address 192.168.70.1 255.255.255.224
  • R1(config-subif)# exit
  • ! VLAN 100 – Consults
  • R1(config)# interface fa0/0.100
  • R1(config-subif)# encapsulation dot1Q 100
  • R1(config-subif)# ip address 10.10.100.1 255.255.255.224
  • R1(config-subif)# exit
  • ! VLAN 110 – Partners
  • R1(config)# interface fa0/0.110
  • R1(config-subif)# encapsulation dot1Q 110
  • R1(config-subif)# ip address 10.10.110.1 255.255.255.224
  • R1(config-subif)# exit
  • ! DHCP  Exkludera IP-adresser
  • R1(config)# ip dhcp excluded-address 172.24.10.1 172.24.10.9
  • R1(config)# ip dhcp excluded-address 172.24.20.1 172.24.20.9
  • R1(config)# ip dhcp excluded-address 172.24.30.1 172.24.30.9
  • R1(config)# ip dhcp excluded-address 192.168.50.1 192.168.50.9
  • R1(config)# ip dhcp excluded-address 192.168.60.1 192.168.60.9
  • R1(config)# ip dhcp excluded-address 192.168.70.1 192.168.70.9
  • R1(config)# ip dhcp excluded-address 10.10.100.1 10.10.100.9
  • R1(config)# ip dhcp excluded-address 10.10.110.1 10.10.110.9
  • ! DHCP pool konfiguration VLAN 10
  • R1(config)# ip dhcp pool ITpool
  • R1(dhcp-config)# network 172.24.10.0 255.255.255.224
  • R1(dhcp-config)# default-router 172.24.10.1
  • R1(dhcp-config)# dns-server 8.8.8.8
  • R1(dhcp-config)# exit
  • ! DHCP pool konfiguration VLAN 20
  • R1(config)# ip dhcp pool HRpool
  • R1(dhcp-config)# network 172.24.20.0 255.255.255.224
  • R1(dhcp-config)# default-router 172.24.20.1
  • R1(dhcp-config)# dns-server 8.8.8.8
  • R1(dhcp-config)# exit
  • ! DHCP pool konfiguration VLAN 30
  • R1(config)# ip dhcp pool ADMpool
  • R1(dhcp-config)# network 172.24.30.0 255.255.255.224
  • R1(dhcp-config)# default-router 172.24.30.1
  • R1(dhcp-config)# dns-server 8.8.8.8
  • R1(dhcp-config)# exit
  • ! DHCP pool konfiguration VLAN 50
  • R1(config)# ip dhcp pool DEVpool
  • R1(dhcp-config)# network 192.168.50.0 255.255.255.224
  • R1(dhcp-config)# default-router 192.168.50.1
  • R1(dhcp-config)# dns-server 8.8.8.8
  • R1(dhcp-config)# exit
  • ! DHCP pool konfiguration VLAN 60
  • R1(config)# ip dhcp pool DESIGNpool
  • R1(dhcp-config)# network 192.168.60.0 255.255.255.224
  • R1(dhcp-config)# default-router 192.168.60.1
  • R1(dhcp-config)# dns-server 8.8.8.8
  • R1(dhcp-config)# exit
  • ! DHCP pool konfiguration VLAN 70
  • R1(config)# ip dhcp pool PRODpool
  • R1(dhcp-config)# network 192.168.70.0 255.255.255.224
  • R1(dhcp-config)# default-router 192.168.70.1
  • R1(dhcp-config)# dns-server 8.8.8.8
  • R1(dhcp-config)# exit
  • ! DHCP pool konfiguration VLAN 100
  • R1(config)# ip dhcp pool CONSULTSpool
  • R1(dhcp-config)# network 10.10.100.0 255.255.255.224
  • R1(dhcp-config)# default-router 10.10.100.1
  • R1(dhcp-config)# dns-server 8.8.8.8
  • R1(dhcp-config)# exit
  • ! DHCP pool konfiguration VLAN 110
  • R1(config)# ip dhcp pool PARTNERSpool
  • R1(dhcp-config)# network 10.10.110.0 255.255.255.224
  • R1(dhcp-config)# default-router 10.10.110.1
  • R1(dhcp-config)# dns-server 8.8.8.8
  • R1(dhcp-config)# exit
  • R1(config)# end
  • R1# write memory