Seguridad y Redes

Tips & Video Tutoriales, Wifislax, VMware, GNS3, VirtualBox, CCNA, Cisco Routers & Switches, [ Programming ]

Configuración de SVIs en un Switch de Capa 3

Las VLAN dividen dominios de transmisión en un entorno LAN. Siempre que los host de una VLAN necesitan comunicarse con algun otro host en otra VLAN, debe enrutarse el tráfico entre ellos. Esto se denomina ruteo interVLAN. En los switches Catalyst, se logra al crear interfaces de Capa 3 (Switch Virtual Interface - SVI).

Host1
IP: 10.1.1.5
Default Gateway: 10.1.1.1
Subnet: 255.255.255.0 

Host2
IP: 10.1.2.2
Default Gateway: 10.1.2.1
Subnet: 255.255.255.0
Topologia en GNS3 utilizando la imagen vIOS-L2 y Core Linux.

Configuracion en Core Linux 1.
labs login: delfi
Password:
                                   /\_/\
                                  ( o.o )
                                   > ^ <
                              delfirosales.com
delfi@labs:~$ 
delfi@labs:~$ sudo su
root@labs:/home/delfi# ifconfig eth0 10.1.1.5 netmask 255.255.255.0 up
root@labs:/home/delfi# route add default gw 10.1.1.1
Core Linux 2.
delfi@labs:~$ 
delfi@labs:~$ sudo su
root@labs:/home/delfi# ifconfig eth0 10.1.2.2 netmask 255.255.255.0 up
root@labs:/home/delfi# route add default gw 10.1.2.1
root@labs:/home/delfi# 
Habilitar ruteo en el Switch
vIOS-L2#configure terminal
vIOS-L2(config)#ip routing 
Configuracion y creacion de VLANs
vIOS-L2(config)#interface gigabitEthernet0/1
vIOS-L2(config-if)#switchport access vlan 2
% Access VLAN does not exist. Creating vlan 2
vIOS-L2(config-if)#switchport mode access 
vIOS-L2(config-if)#exit

vIOS-L2(config)#interface gigabitEthernet0/2
vIOS-L2(config-if)#switchport access vlan 3
% Access VLAN does not exist. Creating vlan 3
vIOS-L2(config-if)#switchport mode access 
vIOS-L2(config-if)#exit
Verificacion de las VLANs creadas anterior.
vIOS-L2#show vlan   

VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Gi0/0, Gi0/3
2    VLAN0002                         active    Gi0/1
3    VLAN0003                         active    Gi0/2
100  VLAN100                          active    
200  VLAN0200                         active    
300  VLAN0300                         active    
1002 fddi-default                     act/unsup 
1003 trcrf-default                    act/unsup 
1004 fddinet-default                  act/unsup 
1005 trbrf-default                    act/unsup 

VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1    enet  100001     1500  -      -      -        -    -        0      0   
2    enet  100002     1500  -      -      -        -    -        0      0   
3    enet  100003     1500  -      -      -        -    -        0      0   
100  enet  100100     1500  -      -      -        -    -        0      0   
200  enet  100200     1500  -      -      -        -    -        0      0   
300  enet  100300     1500  -      -      -        -    -        0      0   
1002 fddi  101002     1500  -      -      -        -    -        0      0   
          
VLAN Type  SAID       MTU   Parent RingNo BridgeNo Stp  BrdgMode Trans1 Trans2
---- ----- ---------- ----- ------ ------ -------- ---- -------- ------ ------
1003 trcrf 101003     4472  1005   3276   -        -    srb      0      0   
1004 fdnet 101004     1500  -      -      -        ieee -        0      0   
1005 trbrf 101005     4472  -      -      15       ibm  -        0      0   


VLAN AREHops STEHops Backup CRF
---- ------- ------- ----------
1003 7       7       off

Primary Secondary Type              Ports
------- --------- ----------------- ------------------------------------------


Creacion de la SVI 2.
vIOS-L2(config)#interface vlan 2
vIOS-L2(config-if)#ip address 10.1.1.1 255.255.255.0
vIOS-L2(config-if)#no shutdown 
vIOS-L2(config-if)#exit
Creacion de la SVI 3.
vIOS-L2(config)#interface vlan 3
vIOS-L2(config-if)#ip address 10.1.2.1 255.255.255.0
vIOS-L2(config-if)#no shutdown 
vIOS-L2(config-if)#end
vIOS-L2#
Si ingresamos el siguiente comando podremos observar que las interfaces se encuentran arriba.
vIOS-L2#show ip interface brief
Interface              IP-Address      OK? Method Status                Protocol
GigabitEthernet0/0     unassigned      YES unset  up                    up      
GigabitEthernet0/1     unassigned      YES unset  up                    up      
GigabitEthernet0/2     unassigned      YES unset  up                    up      
GigabitEthernet0/3     unassigned      YES unset  up                    up      
Vlan2                  10.1.1.1        YES manual up                    up      
Vlan3                  10.1.2.1        YES manual up                    up      
vIOS-L2#
Tambien podremos observar la tabla de ruteo con el comando show ip route.
vIOS-L2#show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
       a - application route
       + - replicated route, % - next hop override

Gateway of last resort is not set

      10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C        10.1.1.0/24 is directly connected, Vlan2
L        10.1.1.1/32 is directly connected, Vlan2
C        10.1.2.0/24 is directly connected, Vlan3
L        10.1.2.1/32 is directly connected, Vlan3
vIOS-L2#

vIOS-L2#show interfaces vlan 2
Vlan2 is up, line protocol is up 
  Hardware is Ethernet SVI, address is 0000.ab5a.8002 (bia 0000.ab5a.8002)
  Internet address is 10.1.1.1/24
  MTU 1500 bytes, BW 1000000 Kbit/sec, DLY 10 usec, 
     reliability 255/255, txload 1/255, rxload 1/255
  Encapsulation ARPA, loopback not set
  Keepalive not supported 
  ARP type: ARPA, ARP Timeout 04:00:00
  Last input 00:00:10, output never, output hang never
  Last clearing of "show interface" counters never
  Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
  Queueing strategy: fifo
  Output queue: 0/40 (size/max)
  5 minute input rate 0 bits/sec, 0 packets/sec
  5 minute output rate 0 bits/sec, 0 packets/sec
     652 packets input, 98538 bytes, 0 no buffer
     Received 0 broadcasts (0 IP multicasts)
     0 runts, 0 giants, 0 throttles 
     0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored
     17 packets output, 1054 bytes, 0 underruns
     0 output errors, 0 interface resets
     0 unknown protocol drops
     0 output buffer failures, 0 output buffers swapped out
vIOS-L2#
Verificacion de Core Linux 1 a Core Linux 2.


Otros comandos de verificacion.
vIOS-L2#show interfaces vlan 3
vIOS-L2#show interface gigabitEthernet0/0
vIOS-L2#show interfaces gigabitEthernet0/0 switchport
vIOS-L2#show vlan brief
Descargar Core Linux: LinuxCore-6.4.1.img

Routing entre VLANs (InterVLAN Routing)

Configurar el siguiente escenario. Donde tenemos dos Switches, en cada uno de los switches configuraremos dos VLANs, uno con nombre de vlan10 y el segundo con nombre de vlan20. Cada uno de los switches tendra conectado un host, el primero switch tendra un host que estara en la vlan10 y el segundo switch tendra otro host que estara en la vlan20.
Inter-VLAN Routing
Para que halla comunicación entre vlans en diferentes segmentos de red necesitaremos un dispositivo de capa 3, un router con como se ve en la imagen. A este router le configuraremos dos subinterfaces el cual nos ayudara a que halla comunicion entre vlans.

Inter-VLAN Routing en GNS3
Lo primero que haremos es crear dos vlan en cada switch (sin el VTP).
SW1(config)#vlan 10
SW1(config-vlan)#name VLAN10
SW1(config-vlan)#vlan 20
SW1(config-vlan)#name VLAN20
SW1(config-vlan)#end

SW2(config)#vlan 10
SW2(config-vlan)#name VLAN10
SW2(config-vlan)#vlan 20
SW2(config-vlan)#name VLAN20
SW2(config-vlan)#end
Verificamos
SW1#show vlan-sw
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa1/0, Fa1/1, Fa1/2, Fa1/3
                                                Fa1/4, Fa1/5, Fa1/6, Fa1/7
                                                Fa1/8, Fa1/9, Fa1/10, Fa1/11
                                                Fa1/12, Fa1/13, Fa1/14, Fa1/15
10   VLAN10                           active   
20   VLAN20                           active   
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup
Una vez creada las VLANs, ahora las asignaremos a los puertos.
SW1(config)#int f1/3
SW1(config-if)#switchport access vlan 10
SW1(config-if)#end
SW1#show vlan-sw brief
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa1/0, Fa1/1, Fa1/2, Fa1/4
                                                Fa1/5, Fa1/6, Fa1/7, Fa1/8
                                                Fa1/9, Fa1/10, Fa1/11, Fa1/12
                                                Fa1/13, Fa1/14, Fa1/15
10   VLAN10                           active    Fa1/3
20   VLAN20                           active   
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup
SW2(config)#int f1/2
SW2(config-if)#switchport access vlan 20
SW2(config-if)#end
SW2#show vlan-sw brief
VLAN Name                             Status    Ports
---- -------------------------------- --------- -------------------------------
1    default                          active    Fa1/0, Fa1/1, Fa1/3, Fa1/4
                                                Fa1/5, Fa1/6, Fa1/7, Fa1/8
                                                Fa1/9, Fa1/10, Fa1/11, Fa1/12
                                                Fa1/13, Fa1/14, Fa1/15
10   VLAN10                           active   
20   VLAN20                           active    Fa1/2
1002 fddi-default                     act/unsup
1003 token-ring-default               act/unsup
1004 fddinet-default                  act/unsup
1005 trnet-default                    act/unsup
Configuramos los Puertos en modo Trunk.
SW1(config)#int f1/2
SW1(config-if)#switchport mode trunk
SW1(config)#int f1/1
SW1(config-if)#switchport trunk encapsulation dot1q
SW1(config-if)#switchport mode trunk
SW1(config-if)#end
SW1#show int trunk

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

Port      Vlans allowed on trunk
Fa1/1     1-4094
Fa1/2     1-4094

Port      Vlans allowed and active in management domain
Fa1/1     1,10,20
Fa1/2     1,10,20

Port      Vlans in spanning tree forwarding state and not pruned
Fa1/1     none
Fa1/2     1,10,20
SW2(config)#int f1/1
SW2(config-if)#switchport mode trunk
SW2#show int trunk

Port      Mode         Encapsulation  Status        Native vlan
Fa1/1     on           802.1q         trunking      1

Port      Vlans allowed on trunk
Fa1/1     1-4094

Port      Vlans allowed and active in management domain
Fa1/1     1,10,20

Port      Vlans in spanning tree forwarding state and not pruned
Fa1/1     none
Configuramos el Router
R1(config)#int f0/0
R1(config-if)#no ip address
R1(config-if)#no shutdown
R1(config-if)#int f0/0.10
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip address 172.17.10.1 255.255.255.0
R1(config-subif)#exit
R1(config)#int f0/0.20
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip add 172.17.20.1 255.255.255.0
R1(config-subif)#end
R1#show ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES manual up                    up     
FastEthernet0/0.10         172.17.10.1     YES manual up                    up     
FastEthernet0/0.20         172.17.20.1     YES manual up                    up     
FastEthernet0/1            unassigned      YES unset  administratively down down   
R1#
Configuramos una IP y el Default Gateway a cada uno de los hosts (qemu host):
PC1:
ifconfig eth0 172.17.10.10 netmask 255.255.255.0 up
route add default gw 172.17.10.1
PC2:
ifconfig eth0 172.17.20.10 netmask 255.255.255.0 up
route add default gw 172.17.20.1
Verificamos con un ping desde cada PC.