Multi-VLAN Segmentation with Inter-VLAN Routing

Overview

Simulate a multi-department office with separate VLANs, I created a diagram with 6 PCs connected to one switch and router.

Skills Demonstrated
Creating and assigning VLANs for department-based segmentation
Calculating and applying subnetting for scalable IP allocation
Configuring access ports for VLAN membership on a switch
Using straight-through cabling to connect endpoint devices
Implementing inter-VLAN routing using separate router interfaces per VLAN
Assigning gateway IP addresses based on subnet design
Verifying VLAN-to-VLAN communication using ping tests
Using CLI commands for hostname config, password hardening, and interface setup
Interpreting router and switch output to validate configuration
Tools Used
Cisco Packet Tracer
Switch Configuration CLI
Router Configuration CLI
Straight-through Ethernet Cables
PC Static IP Settings Panel
Command Line Tools (ping, show vlan brief, show ip interface brief)

1. Network Topology

I separated 6 PCs into 3 VLANs per department:

  • VLAN10: Sales
  • VLAN20: HR
  • VLAN30: Engineering

For each VLAN in this example, I went with a /26 subnet which would give me 62 usable hosts to allot for each department to add new PCs to the subnet in the future:

VLANDepartmentNetwork AddressUsable RangeBroadcast AddressGateway
VLAN10Sales10.0.0.010.0.0.1 - 10.0.0.6210.0.0.6310.0.0.62
VLAN20HR10.0.0.6410.0.0.65 - 10.0.0.12610.0.0.12710.0.0.126
VLAN30Engineering10.0.0.12810.0.0.129 - 10.0.0.19010.0.0.19110.0.0.190

Since they are different devices, I then connected straight through cables from each PC to the switch:

  • PC1 F0/0 → SW1 F0/1 (VLAN10)
  • PC2 F0/0 → SW1 F1/1 (VLAN10)
  • PC3 F0/0 → SW1 F2/1 (VLAN20)
  • PC4 F0/0 → SW1 F3/1 (VLAN20)
  • PC5 F0/0 → SW1 F4/1 (VLAN30)
  • PC6 F0/0 → SW1 F5/1 (VLAN30)

For this lab, since I am not performing Router on a Stick (ROAS) or using a Layer 3/Multilayer Switch for inter-vlan routing, I am going to connect 3 straight-through cables from the switch to the router, one for each VLAN for inter-vlan routing:

  • SW1 G7/1 → R1 G0/0 (VLAN10)
  • SW1 G8/1 - R1 G0/1 (VLAN20)
  • Sw1 G9/1 - R1 G0/2 (VLAN30)

2. PC Configuration

Then I go into each PC's config settings and set the appropriate IP address and subnet mask based on the /26 subnet:

I then go to each PC and set the default gateway in the config settings to the last usable address of each subnet range. This is necessary for the inter-vlan routing when I set the IP addresses on the router later:

The final IP configurations for the PCs:

PCIP AddressSubnet MaskGateway
PC110.0.0.1255.255.255.19210.0.0.62
PC210.0.0.2255.255.255.19210.0.0.62
PC310.0.0.65255.255.255.19210.0.0.126
PC410.0.0.66255.255.255.19210.0.0.126
PC510.0.0.129255.255.255.19210.0.0.190
PC610.0.0.130255.255.255.19210.0.0.190

After setting up the IP address and subnet mask for each PC, I do a quick ping check on PC1.

From PC1, I first ping 10.0.0.2 (PC2) to confirm that I get replies, and then ping 10.0.0.65 (PC3) which is in a different subnet. I do this to confirm that it can't yet reach PC3 since it's in a different subnet. They will be able to ping each other later once I set up inter-vlan routing.


3. Switch Configuration

Now, I begin the process to add each PC to their appropriate VLAN by setting the access ports on the switch to VLAN. Before that, I set up some initial settings on the switch.

First, I enable an MD5 secret password on the switch for security best practices and save it to startup configuration:

Switch> enable
Switch# conf t
Switch(config)# enable secret [password]
Switch(config)# exit
Switch# write

Then I change the hostname from "Switch" to "SW1" just to make it easier to know which switch it is:

Switch> enable
Switch# conf t
Switch(config)# hostname SW1
SW1(config)# exit
SW1# write

Now that I enabled the secret password and changed the hostname, it's time to configure the interfaces to join the VLANs.

First I run "show vlan brief" in the following commands to see the VLAN status of each ports. We can see that the default native VLAN1 and the other defaults of VLAN1002 - 1005 are set and that each port on the switch is currently in VLAN1:

SW1> enable
SW1# show vlan brief
VLANNameStatusPorts
1defaultactiveFa0/1, Fa1/1, Fa2/1, Fa3/1, Fa4/1, Fa5/1, Fa6/1, Gig7/1, Gig8/1, Gig9/1
1002fddi-defaultactive
1003token-ring-defaultactive
1004fddinet-defaultactive
1005trnet-defaultactive

First I configure f0/1, f1/1, and g7/1 on the switch to VLAN10 and name VLAN10 "Sales" by running the following commands:

SW1> enable
SW1# conf t
SW1(config)# int range f0/1,f1/1,g7/1
SW1(config-if-range)# switchport access vlan 10
SW1(config-if-range)# exit
SW1(config)# vlan 10
SW1(config-vlan)# name Sales

Next I configure f2/1, f3/1, g8/1 on the switch to VLAN20 and name VLAN20 "HR" by running the following commands:

SW1> enable
SW1# conf t
SW1(config)# int range f2/1,f3/1,g8/1
SW1(config-if-range)# switchport access vlan 20
SW1(config-if-range)# exit
SW1(config)# vlan 20
SW1(config-vlan)# name HR

Lastly, I configure f4/1, f5/1, and g9/1 on the switch to VLAN30 and name VLAN30 "Engineering" by running the following commands:

SW1> enable
SW1# conf t
SW1(config)# int range f4/1,f5/1,g9/1
SW1(config-if-range)# switchport access vlan 30
SW1(config-if-range)# exit
SW1(config)# vlan 30
SW1(config-vlan)# name Engineering

Now when running "show vlan brief" we can see each port is assigned to the correct VLAN and has the proper name:

VLANNameStatusPorts
1defaultactiveFa6/1
10SalesactiveFa0/1, Fa1/1, Gig7/1
20HRactiveFa2/1, Fa3/1, Gig8/1
30EngineeringactiveFa4/1, Fa5/1, Gig9/1
1002fddi-defaultactive
1003token-ring-defaultactive
1004fddinet-defaultactive
1005trnet-defaultactive

Router Configuration

With the VLANs on the switch configured, now to enable inter-vlan routing.

I must add IP addresses to the ports on the router. I set the IP address on each port to the default gateway I set on each PC in each VLAN. With that being said:

  • g0/0 must have an IP address of 10.0.0.62
  • g0/1 must have an IP address of 10.0.0.126
  • g0/2 must have an IP address of 10.0.0.190.

I run the following commands on g0/0 on the router to add this IP address:

Router> enable
Router# conf t
Router(config)# int g0/0
Router(config-if) ip address 10.0.0.62 255.255.255.192
Router(config-if) no shutdown

I run the following commands on g0/1 on the router to add this IP address:

Router> enable
Router# conf t
Router(config)# int g0/1
Router(config-if) ip address 10.0.0.126 255.255.255.192
Router(config-if) no shutdown

I run the following commands on g0/2 on the router to add this IP address:

Router> enable
Router# conf t
Router(config)# int g0/2
Router(config-if) ip address 10.0.0.190 255.255.255.192
Router(config-if) no shutdown

Now when running "show ip interface brief" we can see that the IP addresses have been added:

InterfaceIP AddressOK?MethodStatusProtocol
GigabitEthernet0/010.0.0.62YESmanualupup
GigabitEthernet0/110.0.0.126YESmanualupup
GigabitEthernet0/210.0.0.190YESmanualupup
Vlan1unassignedYESunsetadministratively downdown

4. Successful Inter-VLAN Connectivity

Now all the links are showing connected and to test inter-vlan connectivity, I ping PC5 in VLAN30 to PC1 in VLAN10 and receive replies.