Configuring Switches and Routers
Configuring Switches and Routers
Switches and routers form the backbone of any network infrastructure. While switches operate at
the Data Link layer (Layer 2) and primarily manage LAN communication, routers operate at the
Network layer (Layer 3) and handle inter-network communication. This guide provides a
fundamental understanding of how to configure switches and routers for basic routing and
switching functionality.
Switches connect devices within the same local area network (LAN), using MAC
addresses to forward frames.
Routers connect multiple networks and direct data packets between them based on IP
addresses.
Configuring these devices involves setting up interfaces, enabling protocols, and applying
security measures to ensure efficient data transfer and secure network operation.
To configure a switch or router, you need to access its CLI. Methods include:
o Console Access: Using a console cable connected to a PC running terminal
emulation software like PuTTY.
o SSH/Telnet: For remote configuration (requires IP address and authentication
setup).
o Web Interface: Some devices offer a graphical web-based interface for
configuration.
2. Basic Switch Configuration
Switch configuration primarily involves setting up VLANs, port settings, and enabling
management capabilities.
Switch> enable
Switch# configure terminal
Switch(config)# hostname Switch1
4. Configure Default Gateway: Specify the router's IP address as the default gateway for
remote management.
5. Set Console and SSH Access: Enable console and SSH access for secure management.
1. Set a Hostname:
Router> enable
Router# configure terminal
Router(config)# hostname Router1
Router1(config)# ip routing
VLANs segment a switch into multiple logical networks to improve performance and security.
1. Create a VLAN:
Switch1(config)# vlan 10
Switch1(config-vlan)# name Sales
5. Inter-VLAN Routing
Inter-VLAN routing allows devices in different VLANs to communicate, which requires a Layer
3 device (router or Layer 3 switch).
Router-on-a-Stick Configuration:
1. Create Subinterfaces:
1. On Router1:
2. On Router2:
Dynamic routing protocols like RIP or OSPF simplify route configuration and adapt to network
changes.
Configuring RIP:
1. Enable RIP:
2. Specify Networks:
1. Scenario: You need to configure a network for a small office with two VLANs (VLAN
10 for Sales, VLAN 20 for IT) and interconnect them via a router.
2. Devices:
o Switch: Configure VLANs 10 and 20.
o Router: Enable inter-VLAN routing using subinterfaces.
3. Steps:
o Assign devices in the Sales department to VLAN 10 and IT to VLAN 20.
o Configure inter-VLAN routing on the router to allow communication between the
two VLANs.
Configuring switches and routers involves establishing their basic functionality and preparing
them for more advanced configurations.
1. Set a Hostname:
Switch> enable
Switch# configure terminal
Switch(config)# hostname Switch1
1. Set Hostname:
Router> enable
Router# configure terminal
Router(config)# hostname Router1
2. Configure Interfaces:
Port security helps prevent unauthorized access to the LAN by limiting the MAC addresses that
can connect to specific switch ports.
6. Verify Configuration:
VLAN Implementation
VLANs segment a network into smaller, isolated networks, improving performance and security.
1. Create VLANs:
Switch1(config)# vlan 10
Switch1(config-vlan)# name Sales
Switch1(config)# vlan 20
Switch1(config-vlan)# name IT
3. Configure a Trunk Port: A trunk port carries traffic for multiple VLANs between
switches or to a router.
4. Verify VLANs:
If DHCP is hosted on a router and clients are in different VLANs, configure the switch to relay
DHCP requests.
Practical Example
Scenario: Implementing a network with two VLANs (Sales and IT), using port security,
and enabling DHCP for each VLAN.
1. Configure VLANs:
o VLAN 10: Sales (192.168.10.0/24)
o VLAN 20: IT (192.168.20.0/24)
2. Set up DHCP on the router for each VLAN:
Router1(config)# ip dhcp pool Sales
Router1(dhcp-config)# network 192.168.10.0 255.255.255.0
Router1(dhcp-config)# default-router 192.168.10.1