🌐 Switch

A switch is a networking device that is used to connect multiple devices within a Local Area Network (LAN), where it receives data from one device and forwards it only to the intended destination device by using MAC addresses, which helps in reducing unnecessary traffic and improving overall network performance as compared to older devices like hubs.

Network Switches | HPE Juniper Networking US

 

🧠 Basic Idea

👉 Switch = Connect devices + Intelligent data forwarding

 

🔌 Role of Switch in Network

In a network, a switch acts as a central connecting device that allows communication between multiple devices such as computers, printers, and servers, while improving network performance by reducing unnecessary traffic.

What is a Network Switch, and How Does It Work?

 

⚙️ Working of Switch

A switch works by learning and storing MAC addresses of connected devices in a table called the MAC Address Table (or CAM Table), and when data arrives, it checks the destination MAC address and forwards the data only to the specific port where the destination device is connected.

 

📌 Simple Working Flow

  • Device sends data 
  • Switch learns source MAC 
  • Stores it in MAC table 
  • Forwards data to correct port 

 

📊 MAC Address Table

The MAC address table is a database maintained by the switch that stores the mapping between MAC addresses and switch ports, which helps the switch to make forwarding decisions efficiently.

Example

MAC AddressPort
AA:BB:CCFa0/1
DD:EE:FFFa0/2

 

📡 Types of Switching :-

1️⃣ Unicast

  • One-to-one communication 
  • Sent to specific device 

 

2️⃣ Broadcast

  • One-to-all communication 
  • Sent to all devices in LAN 

 

3️⃣ Multicast

  • One-to-group communication 
  • Sent to selected devices 

 

📌 Main Functions :-

 

1️⃣ Frame Forwarding

A switch forwards data frames from the source device to the destination device by checking the destination MAC address and sending the data only to the correct port instead of broadcasting it to all ports.

 

2️⃣ MAC Address Learning

Whenever a device sends data, the switch learns the MAC address of that device and stores it in a table along with the port number, which helps the switch in making future forwarding decisions quickly.

 

3️⃣ Filtering

A switch filters unnecessary traffic by ensuring that data is sent only to the required device, which reduces network congestion and improves efficiency.

 

4️⃣ Flooding

If the destination MAC address is not found in the MAC table, the switch sends the frame to all ports except the incoming port, which is called flooding.

 

5️⃣ Loop Prevention

Switches use protocols like STP (Spanning Tree Protocol) to prevent network loops, which can otherwise cause broadcast storms and network failure.

 

6️⃣ VLAN Support

Switches support VLANs, which allow logical segmentation of the network into different groups without changing physical connections.

 

⚡ Advantages of Switch

Switches provide several advantages in modern networks by improving performance and efficiency.

  • Reduces network congestion 
  • Provides dedicated bandwidth 
  • Faster communication 
  • Intelligent forwarding 
  • Supports VLAN 

 

❌ Disadvantages of Switch

  • Costlier than hub 
  • Requires configuration 
  • Cannot route between networks (Layer 2 switch) 

 

 

📊 Types of Switches :-

Switches are mainly classified based on the OSI layer on which they operate, and each type has different capabilities.

1️⃣ Layer 2 Switch

A Layer 2 switch operates on the Data Link Layer of the OSI model and uses MAC addresses to forward data within the same network, making it suitable for communication within a single LAN.

📌 Features

  • Works on Layer 2 
  • Uses MAC address 
  • Cannot perform routing 
  • Used within same network 

2️⃣ Layer 3 Switch

A Layer 3 switch operates on both the Data Link Layer and the Network Layer, which means it can perform switching as well as routing, allowing communication between different networks or VLANs.

📌 Features

  • Works on Layer 2 + Layer 3 
  • Uses MAC + IP address 
  • Can perform routing 
  • Used for Inter-VLAN routing 

 

⚠️ Important Points

  • Switch works on MAC address 
  • Maintains MAC Address Table (CAM Table) 
  • Supports full-duplex communication 
  • Faster than hub 
  • Reduces collisions

 

 

🌐 VLAN (Virtual Local Area Network)

A VLAN (Virtual Local Area Network) is a logical method of dividing a physical network into multiple smaller networks, where devices are grouped together based on their function, department, or requirement instead of their physical location, allowing better control over network traffic, improved security, and efficient management without changing the physical connections.

 

🧠 Basic Idea

👉 VLAN = Logical separation of one network into multiple networks

 

📌 Why VLAN is Used

In a traditional network, all devices connected to a switch belong to the same broadcast domain, which means every broadcast message is received by all devices, leading to unnecessary traffic and reduced performance, so VLAN is used to divide the network into smaller broadcast domains to improve efficiency and reduce congestion.

 

⚙️ Working of VLAN

A VLAN works by assigning switch ports to specific VLAN IDs, and devices connected to those ports become part of that VLAN, where each VLAN behaves like a separate network, and communication is allowed only within the same VLAN unless a routing device is used.

 

📌 Simple Understanding

  • One physical switch 
  • Multiple logical networks (VLANs) 
  • Each VLAN acts like separate network 

 

📊 VLAN Concept (Example)

Consider a company where different departments such as Sales and HR are connected to the same switch, but using VLAN:

  • VLAN 10 → Sales Department 
  • VLAN 20 → HR Department 

Even though both departments are physically connected to the same switch:

  • Sales devices communicate only with Sales 
  • HR devices communicate only with HR 

👉 Communication between VLANs is not possible without routing

 

📊 VLAN Range

  • VLAN ID ranges from 1 to 4094 
  • VLAN 1 is default VLAN 
  • Some VLANs are reserved for special purposes 

 

✨ Advantages of VLAN :-

VLAN provides several advantages in modern networking by improving performance and security.

  • Reduces broadcast traffic 
  • Improves network performance 
  • Provides better security 
  • Logical grouping of devices 
  • Easy network management 

 

❌ Disadvantages of VLAN :-

  • Requires proper configuration 
  • Increases network complexity 
  • Communication between VLANs requires routing 

 

⚠️ Important Points :-

  • VLAN creates separate broadcast domains 
  • Devices in different VLANs cannot communicate directly 
  • VLAN works on Layer 2 
  • Requires Inter-VLAN Routing for communication 

 

🎯 Key Idea

👉 VLAN = One switch → Multiple logical networks


 

⚙️ VLAN Configuration Syntax & Steps

VLAN configuration on a switch is performed by creating VLANs and assigning switch ports to those VLANs so that connected devices become part of a specific logical network.

 

📌 Syntax :

vlan <vlan-id>
name <any-name>
exit

interface <interface-name>
switchport mode access
switchport access vlan <vlan-id>

 

⚙️ Steps to Configure VLAN :-

 

1️⃣ Enter Global Configuration Mode

Switch> enable
Switch# configure terminal

 

2️⃣ Create VLAN

In this step, a VLAN is created using a VLAN ID and a name (any suitable name can be given).

Switch(config)# vlan <vlan-id>
Switch(config-vlan)# name <any-name>
Switch(config-vlan)# exit

 

3️⃣ Assign VLAN to Interface

After creating the VLAN, assign it to a specific interface so that the connected device becomes part of that VLAN.

Switch(config)# interface <interface-name>
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan <vlan-id>

 

4️⃣ Assign VLAN to Multiple Interfaces (Optional)

If multiple ports need to be assigned to the same VLAN, interface range can be used.

Switch(config)# interface range <interface-range>
Switch(config-if-range)# switchport mode access
Switch(config-if-range)# switchport access vlan <vlan-id>

 

5️⃣ Repeat for Other VLANs

Repeat the same steps to create and assign additional VLANs.

 

📊 Verification Commands

show vlan brief

 

📖 What to Check

  • VLAN IDs are created 
  • VLAN names are assigned 
  • Interfaces are correctly mapped to VLANs 

 

⚠️ Important Points :-

  • VLAN must be created before assigning ports 
  • Access ports belong to only one VLAN 
  • Ports must be in access mode 
  • Devices in different VLANs cannot communicate without routing


 

📡 VLAN Configuration in Multi-Department Topology 

 

📖 Description

In this topology, a multilayer switch is used to create two VLANs to separate different departments logically:

  • VLAN 150 → Sales Department (192.168.150.0/24) 
  • VLAN 160 → Finance Department (192.168.160.0/24) 

Devices are connected to the multilayer-switch and assigned to their respective VLANs so that communication happens only within the same VLAN.

 

 

⚙️ Configuration :-

 

🔧 Step 1: Enter Configuration Mode

Switch> enable
Switch# configure terminal

 

🔧 Step 2: Create VLANs

Switch(config)# vlan 150
Switch(config-vlan)# name SALES-DEPT
Switch(config-vlan)# exit

Switch(config)# vlan 160
Switch(config-vlan)# name FINANCE-DEPT
Switch(config-vlan)# exit

 

🔧 Step 3: Assign Ports to VLAN 150 (Sales Dept)

Switch(config)# interface fa0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 150

Switch(config)# interface fa0/2
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 150

👉 (Ports connected to Laptop0 and PC0)

 

🔧 Step 4: Assign Ports to VLAN 160 (Finance Dept)

Switch(config)# interface fa0/3
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 160

Switch(config)# interface fa0/4
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 160

👉 (Ports connected to Laptop1 and PC1)

 

📊 Verification

show vlan brief

👉 🖼️(Place VLAN Verification Image Here)

 

📖 What to Check

  • VLAN 150 and 160 are created 
  • Correct ports assigned to each VLAN 
  • Devices grouped as per departments 

 

⚠️ Important Observation

 

  • Devices in VLAN 150 cannot communicate with VLAN 160 
  • Both VLANs act as separate networks 
  • Inter-VLAN Routing is required for communication 

 

🎯 Key Idea

👉 Same Switch + Multiple VLANs =
Logical separation of departments

 

🎯 Summary

In this topology, VLANs are configured on a multilayer switch to separate Sales and Finance departments into different networks, where ports are assigned to specific VLANs, ensuring that devices communicate only within their own VLAN.

 

 

🌐 Inter-VLAN Routing

Inter-VLAN Routing is the process of enabling communication between devices that are present in different VLANs, where a Layer 3 device such as a router or multilayer switch is used to route traffic from one VLAN to another, because VLANs are separate networks and cannot communicate directly with each other.

 

🧠 Basic Idea

👉 Inter-VLAN Routing =
Communication between different VLANs using routing

 

📌 Why Inter-VLAN Routing is Needed

In a VLAN-based network, each VLAN acts as a separate broadcast domain, which means devices in different VLANs cannot communicate directly, so Inter-VLAN Routing is required to allow communication between these VLANs when needed.

 

⚙️ Working of Inter-VLAN Routing

Inter-VLAN Routing works by using a Layer 3 device that has interfaces or virtual interfaces for each VLAN, where the device receives data from one VLAN, checks the destination IP address, and then forwards the data to the correct VLAN, enabling communication between different networks.

 

📌 Simple Flow

  • Device in VLAN 10 sends data 
  • Data goes to Layer 3 device 
  • Routing decision is made 
  • Data forwarded to VLAN 20 

 

⚡ Advantages of Inter-VLAN Routing :-

Inter-VLAN routing provides several advantages by enabling communication while maintaining network segmentation.

  • Allows communication between VLANs 
  • Improves network flexibility 
  • Maintains security with controlled communication 
  • Efficient use of network resources 

 

❌ Disadvantages of Inter-VLAN Routing :-

  • Requires Layer 3 device 
  • Configuration complexity 
  • Cost increases (for multilayer switch) 

 

⚠️ Important Points :-

  • VLANs are separate networks 
  • Communication requires routing 
  • Uses IP addresses (Layer 3) 
  • Multilayer switch is faster than router


 

 

📌 Configuration Syntax (Multilayer Switch - SVI Method)

ip routing

interface vlan <vlan-id>
ip address <gateway-ip> <subnet-mask>
no shutdown

 

⚙️ Steps to Configure Inter-VLAN Routing :

 

1️⃣ Enter Global Configuration Mode

Switch> enable
Switch# configure terminal

 

2️⃣ Enable Routing

In this step, routing is enabled on the multilayer switch so that it can perform Layer 3 operations.

Switch(config)# ip routing

 

3️⃣ Create VLAN Interfaces (SVI)

For each VLAN, a virtual interface is created so that the switch can act as a gateway for that VLAN.

Switch(config)# interface vlan <vlan-id>
Switch(config-if)# ip address <gateway-ip> <subnet-mask>
Switch(config-if)# no shutdown

 

4️⃣ Repeat for Other VLANs

The same process is repeated for all VLANs to enable communication between them.

 

5️⃣ Assign VLANs to Switch Ports

Ports must be assigned to VLANs so that devices become part of the respective VLANs.

 

6️⃣ Configure Default Gateway on Devices

Each device must use the VLAN interface IP as its default gateway.

 

📊 Verification Commands :-

show ip route

show vlan brief

show ip interface brief

 

📖 What to Check

  • VLAN interfaces are up 
  • IP addresses are assigned 
  • Routes are present 
  • VLANs are active 

 

⚠️ Important Points

  • Must enable ip routing 
  • Each VLAN must have one SVI (gateway) 
  • Devices must use correct default gateway 
  • VLAN must be created before SVI 


 

 

🌐 VLAN & Inter-VLAN Routing Configuration in Multi-Department Topology 📡

 

📖 Description

In this topology, a multilayer switch is used to create two VLANs for different departments, and Inter-VLAN routing is configured so that devices from different VLANs can communicate with each other through the switch acting as a Layer 3 device.

  • VLAN 150 → Sales Department (192.168.150.0/24) 
  • VLAN 160 → Finance Department (192.168.160.0/24) 

 

⚙️ Configuration :-

 

🔧 Step 1: Enter Configuration Mode

Switch> enable
Switch# configure terminal

 

🔧 Step 2: Create VLANs

Switch(config)# vlan 150
Switch(config-vlan)# name SALES-DEPT
Switch(config-vlan)# exit

Switch(config)# vlan 160
Switch(config-vlan)# name FINANCE-DEPT
Switch(config-vlan)# exit

 

🔧 Step 3: Assign Ports to VLAN 150 (Sales)

Switch(config)# interface fa0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 150

Switch(config)# interface fa0/2
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 150

 

🔧 Step 4: Assign Ports to VLAN 160 (Finance)

Switch(config)# interface fa0/3
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 160

Switch(config)# interface fa0/4
Switch(config-if)# switchport mode access
Switch(config-if)# switchport access vlan 160

 

🔧 Step 5: Enable Routing

Switch(config)# ip routing

 

🔧 Step 6: Configure VLAN Interfaces (SVI)

Switch(config)# interface vlan 150
Switch(config-if)# ip address 192.168.150.1 255.255.255.0
Switch(config-if)# no shutdown
Switch(config-if)# exit

Switch(config)# interface vlan 160
Switch(config-if)# ip address 192.168.160.1 255.255.255.0
Switch(config-if)# no shutdown
Switch(config-if)# exit

 

💻 End Device Configuration :-

📌 Sales Devices :

IP Address: 192.168.150.x
Subnet Mask: 255.255.255.0
Gateway: 192.168.150.1

 

📌 Finance Devices :

IP Address: 192.168.160.x
Subnet Mask: 255.255.255.0
Gateway: 192.168.160.1

 

📊 Verification :

🔍 Check VLAN : show vlan brief

 

🔗 Connectivity Test :

📖 Test Scenario

👉 Ping from Sales VLAN → Finance VLAN

ping 192.168.160.2

 

✅ Result

  • Ping successful 
  • VLANs are communicating 
  • Inter-VLAN routing working properly 

 

⚠️ Important Points :-

  • VLAN separates networks logically 
  • Inter-VLAN routing enables communication 
  • Multilayer switch performs routing internally 
  • Default gateway must be correct 

 

🎯 Key Idea

👉 VLAN + Inter-VLAN Routing =
Separation + Communication

 

🎯 Summary

In this topology, VLANs are configured to separate departments, and Inter-VLAN routing is enabled using a multilayer switch so that devices from different VLANs can communicate efficiently.