Comparison of VLAN Vs Subnet in TCP
Comparison of VLAN Vs Subnet in TCP
A few decades ago, flat networks were the norm. I remember in my very
first job as a network engineer, most of our clients’ networks consisted of a
single broadcast domain (VLAN) and a huge single flat Layer 3 network
(usually in the 10.0.0.0 range).
As time passed by and networks started to become bigger and bigger, flat
networks were simply not manageable, not to say that they even had lots of
problems because of the single broadcast nature of the network.
VLANs and Subnets are two of the most basic building blocks of TCP/IP
networks and are nowadays used extensively to segment-down big
networks and make them more manageable and efficient.
VLANs work at Layer 2 of the OSI model and are used to separate
LAN traffic in different broadcast domains. Hosts in the same VLAN
can communicate freely between each other. Hosts in different
VLANs can’t communicate by default (unless there is Layer 3 routing
between them).
A Subnet works at Layer 3 of the OSI model and is used to create
smaller Layer 3 network IP ranges from a larger network range.
Let’s compare and discuss in more details the differences between VLANs
and Subnets below. The simple network diagram below will help in our
discussion.
In the network above, we have two VLANs (10 and 20) and two network
Subnets (192.168.10.0/24 and 192.168.20.0/24).
Although the hosts belonging in the two VLANs are connected to the same
Switch, they can’t communicate between them via the switch.
What is a VLAN
Virtual Local Area Networks or VLANs are a method of separating ethernet
traffic flowing through a LAN network at Layer 2 or the Data Link layer of
the OSI model.
Now, the switch forwards this frame only to other ports that belong in the
same VLAN. If the tag matches the Vlan assigned to that interface then the
packet is allowed through, if it doesn’t match then the packet is dropped.
From a group of 40 people 10 are given passes that open the red door, 10
passes for the green door, 10 passes for the yellow door and 10 passes for
the blue door.
Now you can see that if someone who has a red pass tries to enter the blue
door the pass won’t work so they are unable to talk to the people on the
other side of the blue door, but they can go through the red door and talk to
all the people who also have a red pass and have access to this room.
This is the same principle as Vlan tagging. So, what happens if a Vlan
tagged interface receives a packet that does not have a Vlan tag?
It is important that the Native Vlan matches on both sides of the trunk link
because if the Native Vlan is different the switch will drop this untagged
traffic at the far end of the trunk as it will see a mismatch.
What is a Subnet
A subnet is a Layer 3 IP network range that is derived after breaking down
a large network range into smaller pieces through the subnetting of its IP
address range.
A single class A IP address (with subnet mask 255.0.0.0) would allow 127
networks with 16,777,216 IP host addresses per network.
This would result in a lot of wasted IP addresses even for the largest
networks. This is where subnetting can help.
The original class A IP address can be split into smaller chunks and these
smaller chunks of IP addresses can be used to make many smaller
networks using the same big address range.
To make these smaller networks the subnet mask is changed from a /8 or
255.0.0.0 to another mask that gives a smaller number of usable IP
addresses.
This means that by segmenting down a big IP range into smaller subnets,
you have better management and more efficient use of IP address space.
In real world switched networks, each Subnet is associated with its own
VLAN (as shown on out network diagram above). So, the two terms we
examine here (VLAN and subnet) have a direct mapping between them.
There are times when you may want different Vlans to be able to
communicate. For example, if you have a File Server that is attached to a
switch and configured to be in Vlan 10 and a PC that is attached to the
same switch but configured in Vlan 20, then they will be unable to
communicate at layer 2 because the Vlans are different.
To allow the PC to talk to the Server, a Layer 3 router must perform
the “Inter-VLAN” routing. This is depicted in the basic diagram shown at the
beginning of this article. Another way to provide “Inter-VLAN” routing is by
using SVI on a Layer 3 switch.
This would mean that any devices in Vlan 10 would now be able to
communicate with devices in Vlan 20 and vice versa. Below is the Cisco
configuration to create the two SVI’s:
Enable
Configure terminal
Vlan 10
Name Servers
Vlan 20
Name User_PC
interface Vlan10
Description Servers
ip address 10.0.1.1 255.255.255.0
interface Vlan20
Description User PC’s
ip address 10.0.2.2 255.255.255.0
Once an SVI has been created all devices in Vlan 10 and Vlan 20 will be
able to communicate with each other.
Advantages
The two VLANs create two separate broadcast domains and therefore
Layer 2 traffic in each VLAN will stay inside the VLAN and will not be able
to reach the other VLAN. Thus, hosts will not be able to communicate
between the two broadcast domains.
They are both used in modern networks to separate and control traffic
between hosts and segregating LAN networks. They are both very useful
and essential in network security.
Now, subnetting also creates security isolation if you use a Layer 3/4
Firewall device to control the routing between the Layer 3 subnets. This is
also a common and useful practice in network security.
The absolute best security practice is to have isolation at both VLAN and
Subnet levels. Assign each subnet to its own physical VLAN and have a
network firewall control the traffic between VLANs/subnets.