Exempel 3: DHCP

I detta exempel visas hur en Layer 3-switch (Cisco 3560) konfigureras för att fungera som både VTP-server och DHCP-server för VLAN 10, 20, och 100. Utöver dessa VLAN används även VLAN 100 som management-VLAN samt VLAN 999 som native VLAN, vilket är en vanlig rekommenderad praxis ur säkerhetssynpunkt. Som VTP-server ansvarar MLS-switchen för att centralt skapa och distribuera VLAN-konfigurationer till VTP-klienterna S1, S2, S3 och S4.

Det som är särskilt intressant i denna topologi är att L3-switchen inte enbart fungerar som en traditionell switch, utan även dirigerar trafik mellan VLAN, på samma sätt som en router. Genom att använda SVI:er (Switch Virtual Interface) kan varje VLAN tilldelas en egen default gateway, vilket möjliggör kommunikation mellan flera IP-nät utan behov av en extern router.

För att VLAN-information och användardata ska kunna transporteras mellan MLS-switchen och access-switcharna krävs trunk-förbindelser. Därför konfigureras trunk-läge manuellt på MLS-switchens portar Fa0/1, Fa0/2, Fa0/3 och Fa0/4. På dessa trunkar tillåts endast nödvändiga VLAN, och VLAN 999 används som native VLAN för att minska risken för VLAN-hopping-attacker.

Access-switcharna har stöd för Dynamic Trunking Protocol (DTP) och kan därför automatiskt förhandla fram trunk-läge på de portar som är anslutna till MLS-switchen. I detta exempel krävs därför ingen manuell trunk-konfiguration på access-switcharna. Det är dock viktigt att notera att trunk-lägen i produktionsmiljöer normalt konfigureras statiskt för ökad säkerhet och bättre kontroll.

VLAN 100 används som management-VLAN och kan tilldelas en SVI på respektive switch för fjärradministration via exempelvis SSH eller Telnet, separat från användartrafiken.

Nätverkstopologi

Konfigurationer

  • MLS(config)# no ip domain-lookup
  • MLS(config)# service password-encryption
  • ! --- VTP (server) ---
  • MLS(config)# vtp domain diginto.se
  • MLS(config)# vtp version 2
  • MLS(config)# vtp mode server
  • MLS(config)# vtp password LetmeP@55
  • ! --- VLANs ---
  • MLS(config)# vlan 10
  • MLS(config-vlan)# name LAN10
  • MLS(config-vlan)# exit
  • MLS(config)# vlan 20
  • MLS(config-vlan)# name LAN20
  • MLS(config-vlan)# exit
  • MLS(config)# vlan 30
  • MLS(config-vlan)# name LAN30
  • MLS(config-vlan)# exit
  • MLS(config)# vlan 40
  • MLS(config-vlan)# name LAN40
  • MLS(config-vlan)# exit
  • MLS(config)# vlan 100
  • MLS(config-vlan)# name Management
  • MLS(config-vlan)# exit
  • MLS(config)# vlan 999
  • MLS(config-vlan)# name Native
  • MLS(config-vlan)# exit
  • ! --- Spanning Tree ---
  • MLS(config)# spanning-tree mode pvst
  • MLS(config)# spanning-tree vlan 10,20,30,40,100 root primary
  • ! --- L3 routing ---
  • MLS(config)# ip routing
  • ! --- SVIs (default gateways) ---
  • MLS(config)# interface vlan 10
  • MLS(config-if)# description Connected to VLAN10
  • MLS(config-if)# ip address 192.168.10.1 255.255.255.0
  • MLS(config-if)# no shutdown
  • MLS(config-if)# exit
  • MLS(config)# interface vlan 20
  • MLS(config-if)# description Connected to VLAN20
  • MLS(config-if)# ip address 192.168.20.1 255.255.255.0
  • MLS(config-if)# no shutdown
  • MLS(config-if)# exit
  • MLS(config)# interface vlan 30
  • MLS(config-if)# description Connected to VLAN30
  • MLS(config-if)# ip address 192.168.30.1 255.255.255.0
  • MLS(config-if)# no shutdown
  • MLS(config-if)# exit
  • MLS(config)# interface vlan 40
  • MLS(config-if)# description Connected to VLAN40
  • MLS(config-if)# ip address 192.168.40.1 255.255.255.0
  • MLS(config-if)# no shutdown
  • MLS(config-if)# exit
  • MLS(config)# interface vlan 100
  • MLS(config-if)# description Connected to VLAN100
  • MLS(config-if)# ip address 192.168.100.1 255.255.255.0
  • MLS(config-if)# no shutdown
  • MLS(config-if)# exit
  • ! --- Trunks mot access-switchar ---
  • MLS(config)# interface range fa0/1-4
  • MLS(config-if-range)# description Trunks to S1-S4
  • MLS(config-if-range)# switchport trunk encapsulation dot1q
  • MLS(config-if-range)# switchport mode trunk
  • MLS(config-if-range)# switchport trunk native vlan 999
  • MLS(config-if-range)# switchport trunk allowed vlan 10,20,30,40,100,999
  • MLS(config-if-range)# switchport nonegotiate
  • MLS(config-if-range)# no shutdown
  • MLS(config-if-range)# exit
  • MLS(config)# end
  • MLS# write memory
  • S1(config)# no ip domain-lookup
  • S1(config)# service password-encryption
  • ! VTP konfiguration
  • S1(config)# vtp domain diginto.se
  • S1(config)# vtp version 2
  • S1(config)# vtp mode client
  • S1(config)# vtp password LetmeP@55
  • ! Trunk konfiguration
  • S1(config)# interface fastEthernet0/1
  • S1(config-if)# switchport mode trunk
  • S1(config-if)# switchport trunk allowed vlan 10,20,30,40,100,999
  • S1(config-if)# no shutdown
  • S1(config-if)# exit
  • ! Access portar
  • S1(config)# interface fa 0/2
  • S1(config-if)# switchport mode access
  • S1(config-if)# switchport access vlan 10
  • S1(config-if)# spanning-tree portfast
  • S1(config-if)# exit
  • S1(config)# interface fa 0/3
  • S1(config-if)# switchport mode access
  • S1(config-if)# switchport access vlan 20
  • S1(config-if)# spanning-tree portfast
  • S1(config-if)# exit
  • S1(config)# interface fa 0/4
  • S1(config-if)# switchport mode access
  • S1(config-if)# switchport access vlan 30
  • S1(config-if)# spanning-tree portfast
  • S1(config-if)# exit
  • S1(config)# end
  • S1# write memory
  • ! Verifiering
  • S1# show vtp status
  • S1# show vlan brief
  • S1# show interface brief
  • S2(config)# no ip domain-lookup
  • S2(config)# service password-encryption
  • ! VTP konfiguration
  • S2(config)# vtp domain diginto.se
  • S2(config)# vtp version 2
  • S2(config)# vtp mode client
  • S2(config)# vtp password LetmeP@55
  • ! Trunk konfiguration
  • S2(config)# interface fa0/1
  • S2(config-if)# switchport mode trunk
  • S2(config-if)# switchport trunk allowed vlan 10,20,30,40,100
  • S2(config-if)# no shutdown
  • S2(config-if)# exit
  • ! Access port
  • S2(config)# interface fa 0/2
  • S2(config-if)# switchport mode access
  • S2(config-if)# switchport access vlan 40
  • S2(config-if)# spanning-tree portfast
  • S2(config-if)# exit
  • S2(config)# end
  • S2# write memory
  • ! Verifiering
  • S2# show vtp status
  • S2# show vlan brief
  • S2# show interfaces trunk
  • S3(config)# no ip domain-lookup
  • S3(config)# service password-encryption
  • ! VTP konfiguration
  • S3(config)# vtp domain diginto.se
  • S3(config)# vtp version 2
  • S3(config)# vtp mode client
  • S3(config)# vtp password LetmeP@55
  • ! Trunk konfiguration
  • S3(config)# interface fastEthernet0/1
  • S3(config-if)# switchport mode trunk
  • S3(config-if)# switchport trunk allowed vlan 10,20,30,40,100,999
  • S3(config-if)# no shutdown
  • S3(config-if)# exit
  • ! Access portar
  • S3(config)# interface fa 0/2
  • S3(config-if)# switchport mode access
  • S3(config-if)# switchport access vlan 10
  • S3(config-if)# spanning-tree portfast
  • S3(config-if)# exit
  • S3(config)# interface fa 0/3
  • S3(config-if)# switchport mode access
  • S3(config-if)# switchport access vlan 20
  • S3(config-if)# spanning-tree portfast
  • S3(config-if)# exit
  • S3(config)# interface fa 0/4
  • S3(config-if)# switchport mode access
  • S3(config-if)# switchport access vlan 30
  • S3(config-if)# spanning-tree portfast
  • S3(config-if)# exit
  • S3(config)# end
  • S2# write memory
  • ! Verifiering
  • S3# show vtp status
  • S3# show vlan brief
  • S3# show interfaces trunk
  • S4(config)# no ip domain-lookup
  • S4(config)# service password-encryption
  • ! VTP konfiguration
  • S4(config)# vtp domain diginto.se
  • S4(config)# vtp version 2
  • S4(config)# vtp mode client
  • S4(config)# vtp password LetmeP@55
  • ! Trunk konfiguration
  • S4(config)# interface fastEthernet0/1
  • S4(config-if)# switchport mode trunk
  • S4(config-if)# switchport trunk allowed vlan 10,20,30,40,100,99
  • S4(config-if)# no shutdown
  • S4(config-if)# exit
  • ! Access port
  • S4(config)# interface fa 0/2
  • S4(config-if)# switchport mode access
  • S4(config-if)# switchport access vlan 100
  • S4(config-if)# spanning-tree portfast
  • S4(config-if)# exit
  • S4(config)# end
  • S4# write memory
  • ! Verifiering
  • S4# show vtp status
  • S4# show vlan brief
  • S4# show interfacess trunk
  • ! --- DHCP: reservera (exkludera) några IP -------
  • MLS(config)# ip dhcp excluded-address 192.168.10.1
  • MLS(config)# ip dhcp excluded-address 192.168.20.1
  • MLS(config)# ip dhcp excluded-address 192.168.30.1
  • MLS(config)# ip dhcp excluded-address 192.168.40.1
  • ! --- DHCP pools ---
  • MLS(config)# ip dhcp pool VLAN10
  • MLS(DHCP-config)# network 192.168.10.0 255.255.255.0
  • MLS(DHCP-config)# default-router 192.168.10.1
  • MLS(DHCP-config)# dns-server 8.8.8.8
  • MLS(DHCP-config)# domain-name diginto.se
  • MLS(DHCP-config)# exit
  • MLS(config)# ip dhcp pool VLAN20
  • MLS(DHCP-config)# network 192.168.20.0 255.255.255.0
  • MLS(DHCP-config)# default-router 192.168.20.1
  • MLS(DHCP-config)# dns-server 8.8.8.8
  • MLS(DHCP-config)# domain-name diginto.se
  • MLS(DHCP-config)# exit
  • MLS(config)# ip dhcp pool VLAN30
  • MLS(DHCP-config)# network 192.168.30.0 255.255.255.0
  • MLS(DHCP-config)# default-router 192.168.30.1
  • MLS(DHCP-config)# dns-server 8.8.8.8
  • MLS(DHCP-config)# domain-name diginto.se
  • MLS(DHCP-config)# exit
  • MLS(config)# ip dhcp pool VLAN40
  • MLS(DHCP-config)# network 192.168.40.0 255.255.255.0
  • MLS(DHCP-config)# default-router 192.168.40.1
  • MLS(DHCP-config)# dns-server 8.8.8.8
  • MLS(DHCP-config)# domain-name diginto.se
  • MLS(DHCP-config)# exit
  • MLS(config)# end
  • MLS# write memory