- ${item}

Port Security in Switches
- What is Port Security?
Port Security is a feature in network switches that restricts access to a switch port based on the MAC address of the connected device. It is used to prevent unauthorized devices from accessing the network, thereby enhancing security and preventing attacks such as MAC flooding, spoofing, and unauthorized access.
- Necessity of Port Security
Port security is essential for the following reasons:
- Prevent Unauthorized Access:
- Ensures that only authorized devices can connect to the network.
- Mitigate MAC Flooding Attacks:
- Prevents attackers from flooding the switch's MAC address table, which can cause the switch to enter fail-open mode and broadcast traffic to all ports.
- Enhance Network Security:
- Protects against MAC spoofing and other Layer 2 attacks.
- Control Network Access:
- Limits the number of devices that can connect to a specific port, reducing the risk of rogue devices.
- Compliance:
- Helps meet regulatory and organizational security policies.
- Port Security Mechanisms
Switches implement port security through various mechanisms:
- MAC Address Binding
- Binds a specific MAC address to a switch port.
- Only the device with the authorized MAC address can connect to the port.
- If an unauthorized device attempts to connect, the port can be disabled or the traffic can be blocked.
- Static MAC Address Configuration
- Manually configure the MAC addresses allowed on a port.
- Example: switchport port-security mac-address 00:11:22:33:44:55.
- Dynamic MAC Address Learning
- Automatically learns and allows MAC addresses up to a specified limit.
- Example: Allow up to 5 devices on a port.
- Sticky MAC Addresses
- Combines static and dynamic learning.
- The switch dynamically learns MAC addresses and converts them to sticky (saved) entries.
- These entries persist even after a reboot.
- Violation Modes
- Defines the action taken when a port security violation occurs:
- Protect: Drops packets from unauthorized devices but does not log the violation.
- Restrict: Drops packets and logs the violation.
- Shutdown: Disables the port and logs the violation. The port must be manually re-enabled.
- Defines the action taken when a port security violation occurs:
- Limiting MAC Addresses
- Restricts the number of MAC addresses that can be learned or configured on a port.
- Example: Allow only 1 MAC address per port.
- Implementation of Port Security
Below are the steps to configure port security on a Cisco switch:
Step 1: Enable Port Security
- Enter interface configuration mode and enable port security.
Switch(config)# interface GigabitEthernet0/1
Switch(config-if)# switchport mode access
Switch(config-if)# switchport port-security
Step 2: Set Maximum MAC Addresses
- Specify the maximum number of MAC addresses allowed on the port.
Switch(config-if)# switchport port-security maximum 2
Step 3: Configure MAC Addresses
- Manually assign allowed MAC addresses or use sticky learning.
Switch(config-if)# switchport port-security mac-address 00:11:22:33:44:55
Switch(config-if)# switchport port-security mac-address sticky
Step 4: Set Violation Mode
- Define the action to take when a violation occurs.
Switch(config-if)# switchport port-security violation restrict
Step 5: Verify Configuration
- Check the port security settings.
Switch# show port-security interface GigabitEthernet0/1
- Benefits of Port Security
- Enhanced Security: Prevents unauthorized access and attacks.
- Granular Control: Allows precise control over which devices can connect to the network.
- Simplified Management: Easy to configure and manage using CLI or GUI tools.
- Compliance: Helps meet security policies and regulatory requirements.
- Limitations and Considerations
- MAC Spoofing: Attackers can spoof authorized MAC addresses to bypass port security.
- Management Overhead: Requires manual configuration and monitoring.
- Scalability: May become difficult to manage in large networks with many devices.
- False Positives: Legitimate devices may be blocked if their MAC addresses change.
- Practical Example
Consider a scenario where a switch port is configured for port security:
- Configuration:
- Allow only 1 MAC address (00:11:22:33:44:55).
- Set violation mode to shutdown.
- Operation:
- Device A with MAC 00:11:22:33:44:55 connects to the port.
- Device B with MAC AA:BB:CC:DD:EE:FF attempts to connect.
- The switch detects the violation and shuts down the port.
- Recovery:
- An administrator must manually re-enable the port.