Vai al contenuto

Inter-VLAN Routing con switch Layer 3, VTP e DHCP Relay

Caratteristiche generali

  • Vlan ID 2 "Server", rete IP 192.168.2.0/24, pool DHCP da 192.168.2.101 a 192.168.2.200, gateway 192.168.2.254
  • Vlan ID 3 "Client", rete IP 192.168.3.0/24, , pool DHCP da 192.168.3.101 a 192.168.3.200, gateway 192.168.3.254
  • Vlan ID 4 "Stampanti", rete IP 192.168.4.0/24, , pool DHCP da 192.168.4.101 a 192.168.4.200, gateway 192.168.4.254
  • Configurazione VTP (versione 2)
    • Switch sw0: VTP server
    • Switch sw1 e sw2: VTP client
    • Dominio VTP: azienda
    • Password VTP: 123456
  • I tre pool DHCP sono configurati all'interno del server 192.168.2.1, il quale assegna indirizzi agli host delle VLAN 3 e 4 mediante DHCP Relay. Lo switch Layer 3 svolge la funzione di "intermediario" nella comunicazione tra server DHCP e client non appartenenti al medesimo dominio di broadcast (DHCP Relay Agent)

Soluzione (.pkt)

Inter-VLAN Routing con switch Layer 3

Configurazione dei dispositivi di rete

sw0# configure terminal 

sw0(config)# vlan 2
sw0(config-vlan)# name Server
sw0(config-vlan)# exit

sw0(config)# vlan 3
sw0(config-vlan)# name Client
sw0(config-vlan)# exit

sw0(config)# vlan 4
sw0(config-vlan)# name Stampanti
sw0(config-vlan)# exit

sw0(config)# interface gi1/0/1
sw0(config-if-range)# switchport mode trunk
sw0(config-if-range)# exit

sw0(config)# interface range gi1/0/2
sw0(config-if-range)# switchport mode trunk
sw0(config-if-range)# end

sw0# show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
...
2    Server                           active    
3    Client                           active    
4    Stampanti                        active    
...

sw0# show interfaces trunk

Port        Mode         Encapsulation  Status        Native vlan
Gig1/0/1    on           802.1q         trunking      1
Gig1/0/2    on           802.1q         trunking      1

Port        Vlans allowed on trunk
Gig1/0/1    1-1005
Gig1/0/2    1-1005

Port        Vlans allowed and active in management domain
Gig1/0/1    1,2,3,4
Gig1/0/2    1,2,3,4

Port        Vlans in spanning tree forwarding state and not pruned
Gig1/0/1    1,2,3,4
Gig1/0/2    1,2,3,4

! Configurazione VTP

sw0(config)# vtp mode server 
sw0(config)# vtp domain azienda
sw0(config)# vtp password 123456
sw0(config)# vtp version 2
sw0(config)# end

sw0# show vtp status 

VTP Version capable             : 1 to 2
VTP version running             : 2
VTP Domain Name                 : azienda
VTP Pruning Mode                : Disabled
VTP Traps Generation            : Disabled
...
VTP Operating Mode                : Server
Maximum VLANs supported locally   : 1005
Number of existing VLANs          : 8
Configuration Revision            : 13
...

sw0# configure terminal 

!! Abilitazione dell'IP routing  
sw0(config)# ip routing

! Configurazione delle SVI (Switch Virtual Interface)

sw0(config)# interface vlan 2
sw0(config-if)# ip address 192.168.2.254 255.255.255.0
sw0(config-if)# exit

! Per le VLAN 3 e 4 si attiva anche il DHCP Relay Agent in modo
! da inoltrare i messaggi DHCP sul server DHCP 192.168.2.1
! (il server DHCP deve avere un pool distinto per ciascuna VLAN)

sw0(config)# interface vlan 3
sw0(config-if)# ip address 192.168.3.254 255.255.255.0
sw0(config-if)# ip helper-address 192.168.2.1
sw0(config-if)# exit

sw0(config)# interface vlan 4
sw0(config-if)# ip address 192.168.4.254 255.255.255.0
sw0(config-if)# ip helper-address 192.168.2.1
sw0(config-if)# exit

! Esegue il comando "show" senza uscire dalla modalità di configurazione
sw0(config)# do show ip route
...
C    192.168.2.0/24 is directly connected, Vlan2
C    192.168.3.0/24 is directly connected, Vlan3
C    192.168.4.0/24 is directly connected, Vlan4

! Configurazione dell'interfaccia "routed" 
! per il collegamento punto-punto al router

sw0(config)# interface gi1/0/3
sw0(config-if)# no switchport
sw0(config-if)# ip address 192.168.200.2 255.255.255.252
sw0(config-if)# exit

! Impostazione della default route
sw0(config)# ip route 0.0.0.0 0.0.0.0 192.168.200.1
sw0(config)# end

sw0# show ip route
...
C    192.168.2.0/24 is directly connected, Vlan2
C    192.168.3.0/24 is directly connected, Vlan3
C    192.168.4.0/24 is directly connected, Vlan4
     192.168.200.0/30 is subnetted, 1 subnets
C       192.168.200.0 is directly connected, GigabitEthernet1/0/3
S*   0.0.0.0/0 [1/0] via 192.168.200.1

sw0# copy running-config startup-config

sw1# configure terminal 

sw1(config)# vtp mode client 
sw1(config)# vtp domain azienda
sw1(config)# vtp password 123456
sw1(config)# vtp version 2

sw1(config)# interface fa0/1
sw1(config-if)# switchport mode access
sw1(config-if)# switchport access vlan 2
sw1(config-if)# exit

sw1(config)# interface fa0/2
sw1(config-if)# switchport mode access
sw1(config-if)# switchport access vlan 3
sw1(config-if)# exit

sw1(config)# interface fa0/3
sw1(config-if)# switchport mode access
sw1(config-if)# switchport access vlan 4
sw1(config)# end

! L'interfaccia gi0/1 di default è dinamica (auto), diventa
! automaticamente trunk se collegata a un'altra porta trunk

sw1# show vlan brief

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
...
2    Server                           active    Fa0/1
3    Client                           active    Fa0/2
4    Stampanti                        active    Fa0/3
...

sw1# show interfaces trunk 

Port        Mode         Encapsulation  Status        Native vlan
Gig0/1      auto         n-802.1q       trunking      1

Port        Vlans allowed on trunk
Gig0/1      1-1005

Port        Vlans allowed and active in management domain
Gig0/1      1,2,3,4

Port        Vlans in spanning tree forwarding state and not pruned
Gig0/1      1,2,3,4

sw1# show vtp status

VTP Version capable             : 1 to 2
VTP version running             : 2
VTP Domain Name                 : azienda
VTP Pruning Mode                : Disabled
VTP Traps Generation            : Disabled
Device ID                       : 000A.41B0.8E00
Configuration last modified by 0.0.0.0 at 3-1-93 00:05:55

Feature VLAN : 
--------------
VTP Operating Mode                : Client
Maximum VLANs supported locally   : 255
Number of existing VLANs          : 8
Configuration Revision            : 13
...

sw1# copy running-config startup-config

La configurazione dello switch sw2 è identica a quella dello switch sw1.

R0#  configure terminal 

R0(config)# interface gi0/0
R0(config-if)# ip address 192.168.200.1 255.255.255.252
R0(config-if)# no shutdown
R0(config-if)# exit

! Interfaccia per testare la raggiungibilità della rete Internet     
R0(config)# interface loopback 1
R0(config-if)# ip address 1.2.3.1 255.255.255.0
R0(config-if)# exit

! Regole di route per raggiungere gli host della rete LAN
R0(config)# ip route 192.168.2.0 255.255.255.0 192.168.200.2 
R0(config)# ip route 192.168.3.0 255.255.255.0 192.168.200.2 
R0(config)# ip route 192.168.4.0 255.255.255.0 192.168.200.2
R0(config)# end

R0# copy running-config startup-config