Tasks:
Configure Router on a stick as follows:
1) VLAN 1 = 10.1.1.0/24, VLAN 10 = 10.1.10.0/24, VLAN 20 = 10.1.20.0/24
2) Router = last IP address in subnet
3) Switch = 10.1.1.253/24 only
Configure VLANs on switch (PC1 in VLAN 10 and PC2 in VLAN 20)
4) Configure link between switch and router
5) Make sure PC1 can ping PC2 (PC1 = 10.1.10.1) PC2 = 10.1.20.2)
Download Solved Lab
Solution:
R1#config t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface gigabitEthernet 0/0/0
R1(config-if)#no shut
Next we will configure Native VLAN 1 Interface with IP address 10.1.1.254. Native VLAN is configured per trunk port, it is locally significant and it tells the switch - "if you receive an untagged data into this port, forward it like it is part of the native VLAN number". For example, if we configure the native VLAN on a trunk to be 20, if data without IEEE 802.1q header comes in that port, it will be forwarded in VLAN 20.
There is another very important angle to this concept. The switches are not only putting the received untagged data into the native VLAN, but they are also sending the data in the Native VLAN untagged.
R1(config)#interface gigabitEthernet 0/0/0.1
R1(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0/0.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/0.1, changed state to up
R1(config-subif)#encapsulation dot1Q 1 native
R1(config-subif)#ip address 10.1.1.254 255.255.255.0
R1(config-subif)#exit
Next we configure VLAN 10 interface with IP Address 10.1.10.254
R1(config)#interface gigabitEthernet 0/0/0.10
R1(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0/0.10, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/0.10, changed state to up
R1(config-subif)#en
R1(config-subif)#encapsulation dot1Q 10
R1(config-subif)#ip address 10.1.10.254 255.255.255.0
R1(config-subif)#exit
And finally VLAN 20 with IP Address 10.1.20.254
R1(config)#interface gigabitEthernet 0/0/0.20
R1(config-subif)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0/0.20, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0/0.20, changed state to up
R1(config-subif)#encapsulation dot1Q 20
R1(config-subif)#ip address 10.1.20.254 255.255.255.0
R1(config-subif)#exit
Now we start configuring the Switch. We will create two VLANs in the switch. VLAN 10 and VLAN 20.
S1>
S1>en
S1#config t
Enter configuration commands, one per line. End with CNTL/Z.
S1(config)#
S1(config)#vlan 10
S1(config-vlan)#exit
S1(config)#vlan 20
S1(config-vlan)#
S1(config-vlan)#exit
S1(config)#
Next we will configure interface gigabitEthernet 1/0/1 to act as a trunk port.
S1(config)#interface gigabitEthernet 1/0/1
S1(config-if)#switchport mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be configured to "trunk" mode.
S1(config-if)#switchport trunk encapsulation dot1q
S1(config-if)#switchport mode trunk
Next we will assign ports to the VLANs. gigabitEthernet 1/0/2 will be assigned to VLAN 10 and gigabitEthernet 1/0/3 will be assigned to VLAN 20
S1(config)#interface g
S1(config)#interface gigabitEthernet 1/0/2
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 10
S1(config-if)#exit
S1(config)#
S1(config)#interface gigabitEthernet 1/0/3
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20
S1(config-if)#exit
Next we will assign IP Address to Switch Virtual Interface VLAN 1 and also add a default gateway to to Router IP Address. We will also need to disable IP Routing at the Router so that Router can redirect traffic to the ddefault gateway.
S1(config)#interface vlan 1
S1(config-if)#ip address 10.1.1.253 255.255.255.0
S1(config-if)#no shutdown
S1(config-if)#exit
S1(config)#
S1(config)#ip default-gateway 10.1.1.254
S1(config)#exit
S1#
S1#config t
Enter configuration commands, one per line. End with CNTL/Z.
S1(config)#no ip routing
S1(config)#exit
S1#
%SYS-5-CONFIG_I: Configured from console by console
S1#ping 10.1.20.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.20.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 0/1/7 ms
S1#
Finally we will configure IP Addresses in the PCs. PC1 will be assigned 10.1.10.1