Cisco 2960 Port Security Configuration

Port security restricts the number of MAC addresses that can be learned on a switch port. By limiting the number of devices that can connect to a port, unauthorized devices are prevented from gaining access to the network, reducing the risk of network breaches and unauthorized access.


Configuring port security on a Cisco 9300 switch involves several steps. Port security helps to secure the network by limiting the number of MAC addresses that can be learned on a port. Here’s a step-by-step guide on how to configure port security on a Cisco 9300 switch:

1. Access the Switch

First, connect to your Cisco 9300 switch using either SSH or through the console port. You need administrative privileges to configure port security.

  • ssh admin@your_switch_ip
  • 2. Enter Global Configuration Mode

  • enable
  • configure terminal
  • 3. Select the Interface

    Choose the interface where you want to enable port security. For example, to configure port security on interface GigabitEthernet 1/0/1:

  • interface GigabitEthernet1/0/1
  • 4. Set the Switchport Mode

    Make sure the port is in access mode:

  • switchport mode access
  • 5. Enable Port Security

    Enable port security on the interface:

  • switchport port-security
  • 6. Set the Maximum Number of Secure MAC Addresses

    Specify the maximum number of MAC addresses that can be learned on the interface. For example, to allow a maximum of 2 MAC addresses:

  • switchport port-security maximum 2
  • 7. Set the Violation Mode

    Define what action to take when a security violation occurs. The options are protect, restrict, and shutdown.

  • protect: Discards traffic from unauthorized MAC addresses.
  • restrict: Discards traffic from unauthorized MAC addresses and sends a log message.
  • shutdown: Shuts down the port.
  • For example, to set the violation mode to restrict:

  • switchport port-security violation restrict
  • 8. (Optional) Configure Sticky MAC Addresses

    If you want the switch to automatically learn MAC addresses and add them to the running configuration as sticky addresses:

  • switchport port-security mac-address sticky
  • 9. Verify Configuration

    Exit interface configuration mode and verify your configuration:

  • end
  • show port-security interface GigabitEthernet1/0/1
  • Example Configuration

    Here is a complete example configuration for interface GigabitEthernet1/0/1:

  • enable
  • configure terminal
  • interface GigabitEthernet1/0/1
  • switchport mode access
  • switchport port-security
  • switchport port-security maximum 2
  • switchport port-security violation restrict
  • switchport port-security mac-address sticky
  • end
  • Save the Configuration
  • Don’t forget to save your configuration to make sure it persists after a reboot:

  • write memory

  • Troubleshooting and Additional Commands

    To view the current port security settings on an interface:

  • show port-security interface GigabitEthernet1/0/1
  • To view the port security settings for all interfaces:

  • show port-security
  • To clear security violations and reset the interface:

  • clear port-security all
  • Following these steps will help you configure port security on your Cisco 9300 switch, enhancing the security of your network by controlling the devices that can connect to specific switch ports.

    What is the purpose of port security in cisco switch

    Port security on a Cisco switch serves several important purposes aimed at enhancing the security and integrity of a network. Here are the key purposes of implementing port security:

    1. Prevent Unauthorized Access

    Port security restricts the number of MAC addresses that can be learned on a switch port. By limiting the number of devices that can connect to a port, unauthorized devices are prevented from gaining access to the network, reducing the risk of network breaches and unauthorized access.

    2. Mitigate MAC Address Spoofing

    MAC address spoofing is an attack where an attacker changes the MAC address of their device to match the MAC address of a legitimate device. Port security can help mitigate such attacks by ensuring that only specific, pre-configured MAC addresses are allowed to connect to a port.

    3. Enhance Network Control

    By controlling which devices can connect to the network and limiting the number of MAC addresses per port, network administrators gain better control over the network environment. This control helps in managing the network more effectively, ensuring that only authorized devices are connected.

    4. Prevent MAC Flooding Attacks

    MAC flooding is an attack where an attacker overwhelms the switch's MAC address table with a large number of fake MAC addresses, causing legitimate devices to be dropped from the table. Port security can limit the number of MAC addresses learned on a port, thus preventing the switch's MAC address table from being flooded.

    5. Improve Network Performance and Stability

    By restricting the number of devices that can connect to a port, port security can help maintain network performance and stability. This is particularly important in environments where network resources are limited or where high performance is critical.

    6. Simplify Network Management

    Port security can simplify network management by allowing administrators to configure and enforce security policies at the switch port level. This makes it easier to manage and secure the network, especially in large and complex network environments.

    7. Provide Accountability and Monitoring

    With port security, administrators can monitor and log port security violations, providing accountability and insights into potential security threats. This logging helps in identifying and responding to security incidents more effectively.


    Example Scenarios

  • Corporate Office: In a corporate environment, port security can ensure that only authorized employees' devices can connect to the network, preventing unauthorized devices from accessing sensitive information.
  • Educational Institutions: In schools or universities, port security can prevent students from connecting unauthorized devices to the network, ensuring that network resources are used appropriately and securely.
  • Data Centers: In data centers, port security can help maintain the integrity of critical systems by ensuring that only authorized servers and devices can connect to the network infrastructure.
  • By implementing port security, organizations can significantly enhance their network security posture, reduce the risk of unauthorized access, and maintain a stable and secure network environment.
  • Post a Comment

    Previous Post Next Post