3.1 Switch Basics
1. Basics of Switches
In Packet Tracer, switches and routers are the two most fundamental network devices. They play different roles in a network and have different functionalities.
A switch operates primarily at Layer 2 (Data Link Layer) of the OSI model, though some modern switches can also operate at Layer 3 (Network Layer).
- Function: A switch connects devices (computers, printers, etc.) within the same network (or subnet) and forwards data based on MAC addresses.
3. MAC Address vs IP Address
Communicating solely with MAC addresses across LANs (Local Area Networks) is not possible because MAC addresses are designed for Layer 2 (Data Link Layer) communication, which is limited to the local network segment. Here’s a detailed explanation of why MAC addresses cannot be used for communication across LANs:
3.1 MAC Addresses are Local to a LAN
- MAC addresses are used for communication within the same broadcast domain (e.g., a single LAN or subnet).
- Devices in a LAN use MAC addresses to identify each other at the data link layer.
- MAC addresses are not routable, meaning they cannot be used to send data beyond the local network.
3.2 Routers Do Not Forward MAC Addresses
- Routers operate at Layer 3 (Network Layer) and use IP addresses to route traffic between different networks (LANs).
- When a packet reaches a router:
- The router strips off the Layer 2 header (which contains the source and destination MAC addresses).
- It then uses the IP address in the Layer 3 header to determine the next hop.
- Before forwarding the packet to the next network, the router adds a new Layer 2 header with the MAC addresses of the next hop (e.g., the next router or the destination device in the local network).
3.3 MAC Addresses are Not Unique Across Networks
- MAC addresses are globally unique, but they are not designed to be used for routing across networks.
- There is no mechanism to look up or route traffic based on MAC addresses across multiple LANs.
- IP addresses, on the other hand, are hierarchical and designed for routing across networks.
3.4 Broadcast Domain Limitation
- MAC addresses rely on broadcast communication (e.g., ARP requests) to resolve IP addresses to MAC addresses within the same LAN.
- Broadcast traffic is confined to the local network and does not cross routers. This means:
- Devices in one LAN cannot send broadcast messages (e.g., ARP requests) to devices in another LAN.
- Without a way to resolve MAC addresses across LANs, communication using MAC addresses is impossible.
3.5 IP Addresses are Required for Inter-LAN Communication
- IP addresses are used for communication across LANs because:
- They are hierarchical and routable.
- Routers use IP addresses to determine the best path for forwarding packets between networks.
- IP addresses allow devices in different LANs to communicate by providing a logical addressing scheme that is independent of the physical network.
3.6 Example Scenario
Imagine two LANs connected by a router:
- LAN 1: PC1 (
192.168.1.10
) and PC2 (192.168.1.20
). - LAN 2: PC3 (
192.168.2.10
) and PC4 (192.168.2.20
).
Communication Within the Same LAN
- PC1 can communicate with PC2 using MAC addresses because they are in the same LAN.
- PC1 sends an ARP request to resolve PC2’s MAC address and then sends data using the MAC address.
Communication Across LANs
- PC1 cannot communicate with PC3 using MAC addresses because they are in different LANs.
- Instead:
- PC1 sends data to the default gateway (router) using the router’s MAC address.
- The router forwards the data to PC3 using PC3’s IP address.
- The router uses its own MAC address to communicate with devices in LAN 2.
Why MAC Addresses are Not Enough
- MAC addresses are only useful for communication within the same LAN because:
- They are tied to the physical network.
- They lack the hierarchical structure needed for routing.
- They cannot be used to identify devices across multiple networks.
3. Switch in Packet Tracer
3.1 Types of Switches in Packet Tracer
Packet Tracer provides various types of switches, each with different capabilities:
- Layer 2 Switches: These are basic switches that operate at the Data Link Layer (Layer 2) of the OSI model. They use MAC addresses to forward frames to the correct destination.
- Layer 3 Switches: These switches can perform routing functions (Layer 3) in addition to switching. They support IP routing and can be used to create VLANs and inter-VLAN routing.
- Managed Switches: These switches allow configuration of features like VLANs, STP (Spanning Tree Protocol), and port security.
- Unmanaged Switches: These are plug-and-play switches with no configuration options.
3.2 Basic Functions of Switches
- MAC Address Learning: Switches learn MAC addresses by examining the source MAC address of incoming frames and storing them in a MAC address table.
- Forwarding Frames: Switches forward frames only to the port where the destination MAC address is located, reducing unnecessary traffic.
- Broadcast Handling: Switches forward broadcast frames (e.g., ARP requests) to all ports except the source port.
3.3 Switch Configuration in Packet Tracer
- Accessing the CLI: Switches can be configured via the Command Line Interface (CLI). You can access the CLI by clicking on the switch and selecting the “CLI” tab.
- Basic Commands:
enable
: Enter privileged EXEC mode.configure terminal
: Enter global configuration mode.interface [interface-id]
: Configure specific interfaces (e.g.,interface FastEthernet0/1
).show running-config
: View the current configuration.show mac-address-table
: Display the MAC address table.
3.4 VLANs (Virtual LANs)
- Purpose: VLANs segment a network into smaller broadcast domains, improving security and performance.
- Configuration:
- Create a VLAN:
vlan [vlan-id]
(e.g.,vlan 10
). - Assign ports to a VLAN:
switchport mode access
: Set the port as an access port.switchport access vlan [vlan-id]
: Assign the port to a VLAN.
- Create a VLAN:
- Inter-VLAN Routing: Requires a Layer 3 switch or a router with a “router on a stick” configuration.
3.5 Spanning Tree Protocol (STP)
- Purpose: STP prevents loops in a network by blocking redundant paths.
- Configuration:
- Enable STP:
spanning-tree mode [mode]
(e.g.,spanning-tree mode rapid-pvst
). - Verify STP:
show spanning-tree
.
- Enable STP:
3.6 Port Security
- Purpose: Restricts access to a switch port based on MAC addresses.
- Configuration:
- Enable port security:
switchport port-security
. - Set maximum MAC addresses:
switchport port-security maximum [number]
. - Specify violation actions:
switchport port-security violation [shutdown | restrict | protect]
.
- Enable port security:
3.7 Trunking
- Purpose: Trunk ports carry traffic for multiple VLANs between switches.
- Configuration:
- Set the port to trunk mode:
switchport mode trunk
. - Specify allowed VLANs:
switchport trunk allowed vlan [vlan-list]
.
- Set the port to trunk mode:
3.8 Power over Ethernet (PoE)
- Some switches in Packet Tracer support PoE, which allows them to deliver power to devices like IP phones and wireless access points over Ethernet cables.
- Configuration:
- Check PoE status:
show power inline
.
- Check PoE status:
3.9 Troubleshooting Switches
- Common Issues:
- Connectivity problems: Check cable connections and port status.
- VLAN misconfigurations: Verify VLAN assignments and trunk configurations.
- MAC address table issues: Use
show mac-address-table
to ensure the switch is learning MAC addresses correctly.
- Useful Commands:
show interfaces
: Check the status of interfaces.show vlan
: Verify VLAN configurations.ping
: Test connectivity between devices.
3.10 Simulation Mode in Packet Tracer
- Packet Tracer’s simulation mode allows you to visualize how frames and packets travel through the network.
- Use this mode to observe how switches forward frames, learn MAC addresses, and handle broadcasts.
3.11 Best Practices
- Documentation: Always document your switch configurations, including VLANs, trunk ports, and security settings.
- Regular Backups: Save your configurations using
copy running-config startup-config
. - Testing: Use
ping
andtraceroute
to test connectivity after configuring switches.
3.12 Advanced Features
- EtherChannel: Combines multiple physical links into a single logical link for increased bandwidth and redundancy.
- Configuration:
interface range [interface-range]
, thenchannel-group [number] mode [active | passive | on]
.
- Configuration:
- Quality of Service (QoS): Prioritizes certain types of traffic (e.g., voice or video).
- Configuration: Use
mls qos
andclass-map
commands.
- Configuration: Use
3.13 Real-World Applications
- Enterprise Networks: Switches are used to connect devices within a LAN, segment traffic using VLANs, and provide redundancy using STP.
- Data Centers: High-performance switches are used to handle large volumes of traffic and support virtualization.
4. Example of Switch Configuration in Packet Tracer
-
Drag a Switch:
- Open Packet Tracer and drag a Switch (e.g., 2960 Switch) onto the workspace.
-
Connect Devices to the Switch:
- Use copper straight-through cables to connect computers (or PCs) to the switch.
-
Assign IP Address to PCs:
- Click on each PC.
- Go to the Desktop tab and select IP Configuration.
- Assign a unique IP address (within the same network) to each PC. For example:
- PC1: 192.168.1.2
- PC2: 192.168.1.3
Ensure both PCs are on the same network (e.g., 192.168.1.0/24).
-
Test Connectivity Using Ping:
- On PC1, open the Command Prompt and type the command:
ping 192.168.1.3
- If configured correctly, PC1 will be able to communicate with PC2 through the switch.
Explanation: When PC1 sends a message to PC2, the switch uses MAC addresses to forward the message directly to PC2.
- On PC1, open the Command Prompt and type the command:
5. A Simple Network
Basics of a switch and a router.
A Simple Network