To configure a Cisco Packet Tracer project where a router connects to a switch with two VLANs (VLAN10 and VLAN20), and each VLAN has its subnet, follow these steps:
Table of Contents
Network Design:
- Router:
- Interface:
gi0/0
connected to the switch. - Sub-interfaces configured for each VLAN with IP addresses for inter-VLAN routing.
- Switch:
- VLAN10 and VLAN20 created.
- Ports assigned to each VLAN for devices on each subnet.
- The port connected to the router set as a trunk.
Step-by-Step Configuration:
1. Configure VLANs on the Switch
- Access the Switch CLI:
Switch> enable
Switch# configure terminal
Switch(config)#hostname Howtokh-S
- Create VLAN10 and VLAN20:
Howtokh-S(config)# vlan 10
Howtokh-S(config-vlan)# name VLAN10
Howtokh-S(config-vlan)# exit
Howtokh-S(config)# vlan 20
Howtokh-S(config-vlan)# name VLAN20
Howtokh-S(config-vlan)# exit
Example as below:

- Assign Ports to VLANs (assuming you have two clients, one for each VLAN):
Howtokh-S(config)# interface fa0/1
Howtokh-S(config-if)# switchport mode access
Howtokh-S(config-if)# switchport access vlan 10
Howtokh-S(config-if)#no shutdown
Howtokh-S(config-if)#do wr
Howtokh-S(config-if)# exit
Howtokh-S(config)# interface fa0/2
Howtokh-S(config-if)# switchport mode access
Howtokh-S(config-if)# switchport access vlan 20
Howtokh-S(config-if)#no shutdown
Howtokh-S(config-if)#do wr
Howtokh-S(config-if)# exit
- Configure Trunk Port on the switch to connect to the router:
Howtokh-S(config)# interface gi0/1
Howtokh-S(config-if)# switchport mode trunk
Howtokh-S(config-if)#no shutdown
Howtokh-S(config-if)#do wr
Howtokh-S(config-if)# exit
Save all configuration
Howtokh-S#copy running-config startup-config

2. Configure the Router
- Access the Router CLI:
Router> enable
Router# configure terminal
Router(config)#hostname Howtokh-R
- Configure Sub-interfaces for Each VLAN:
- On the router’s
gi0/0
interface, create sub-interfaces for VLAN10 and VLAN20, assign them IP addresses, and encapsulate each with the appropriate VLAN ID.
Howtokh-R(config)# interface gi0/0.10
Howtokh-R(config-subif)# encapsulation dot1Q 10
Howtokh-R(config-subif)# ip address 10.1.1.1 255.255.255.0
Howtokh-R(config-subif)#description Vlan10
Howtokh-R(config-subif)# do wr
Howtokh-R(config-subif)# exit
Howtokh-R(config)# interface gi0/0.20
Howtokh-R(config-subif)# encapsulation dot1Q 20
Howtokh-R(config-subif)# ip address 192.168.0.1 255.255.255.0
Howtokh-R(config-subif)#description Vlan20
Howtokh-R(config-subif)# do wr
Howtokh-R(config-subif)# exit
- Enable the Router Interface:
Howtokh-R(config)# interface gi0/0
Howtokh-R(config-if)# no shutdown
Howtokh-R(config-if)# exit
3. Configure Static IP Addresses for Clients
- Connect a PC to
fa0/1
for VLAN10 and another PC tofa0/2
for VLAN20.

- PC in VLAN10: Assign IP Address to PC
- IP Address:
10.1.1.X
(e.g.,10.1.1.10
) - Subnet Mask:
255.255.255.0
- Default Gateway:
10.1.1.1


- PC in VLAN20:
For the PC2 in VLAN20, you can follow steps 1 in VLAN10
- IP Address:
192.168.0.X
(e.g.,192.168.0.10
) - Subnet Mask:
255.255.255.0
- Default Gateway:
192.168.0.1
4. Test Connectivity
- Use the
ping
command from each PC to test connectivity with its VLAN gateway. - Ensure PCs in VLAN10 and VLAN20 cannot communicate directly but can reach the router’s respective sub-interface IP addresses for inter-VLAN routing, if configured.

After assigning the IP Address you should ping test to make sure it working or not

This setup enables clients in VLAN10 and VLAN20 to access their designated networks with static IP addresses. You can now ping as well. Learn more…
Discover more from How To Kh
Subscribe to get the latest posts sent to your email.