OVERVIEW OF PORT SECURITY
Port security is a feature of network switch that offers the ability to configure port of network switch so that traffic can be limited to only a specific configured MAC addresses.
To check if the port security is enable or not, we can use following command
switch> enable
switch# show port-security
Note: Port security is disable by default therefore no records available.
To show port security status of a specific port, we can use following command
switch> enable
switch# show port-security interface fa0/1
Port Security : Disable
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disable
Maximum MAC Addresses : 1
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address: VLAN : 0000.0000.0000:0
Security Violation Count : 0
Note: Port security is disable by default
To enable port Security of a specific ports of switch
switch> enable
switch# config t
switch (config) # interface fa0/1
switch (config-if) # switchport mode access
switch (config-if) # switchport port-security
To enable port Security of a range of ports of switch (from fa0/1 to fa0/6)
switch> enable
switch# config t
switch (config) # interface range fa0/1 - 6
switch (config-if) # switchport mode access
switch (config-if) # switchport port-security
Note: It can be enable on access port. Port security feature will not work on three types of ports.
switch> enable
switch # show port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation SecurityAction
(Count) (Count) (Count)
--------------------------------------------------------------------------
Fa0/1 5 0 0 Shutdown
Fa0/2 1 0 0 Shutdown
Fa0/3 1 0 0 Shutdown
Fa0/4 1 0 0 Shutdown
Fa0/5 1 0 0 Shutdown
Fa0/6 1 0 0 Shutdown
--------------------------------------------------------------------------
To check port security status of a specific ports of switch.
switch> enable
switch # show port-security interface fa0/1
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disable
Maximum MAC Addresses : 1
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address: VLAN : 0000.0000.0000:0
Security Violation Count : 0
1. Static
2. Dynamic
3. Sticky
To check if the port security is enable or not, we can use following command
switch> enable
switch# show port-security
Note: Port security is disable by default therefore no records available.
To show port security status of a specific port, we can use following command
switch> enable
switch# show port-security interface fa0/1
Port Security : Disable
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disable
Maximum MAC Addresses : 1
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address: VLAN : 0000.0000.0000:0
Security Violation Count : 0
Note: Port security is disable by default
To enable port Security of a specific ports of switch
switch> enable
switch# config t
switch (config) # interface fa0/1
switch (config-if) # switchport mode access
switch (config-if) # switchport port-security
To enable port Security of a range of ports of switch (from fa0/1 to fa0/6)
switch> enable
switch# config t
switch (config) # interface range fa0/1 - 6
switch (config-if) # switchport mode access
switch (config-if) # switchport port-security
Note: It can be enable on access port. Port security feature will not work on three types of ports.
- Trunk port
- Ether Channel port
- Switch port analyzer port
Note: you can configure port security for trunk port but it is not a part of this article.
To check port security status of all ports of switch.
switch> enable
switch # show port-security
Secure Port MaxSecureAddr CurrentAddr SecurityViolation SecurityAction
(Count) (Count) (Count)
--------------------------------------------------------------------------
Fa0/1 5 0 0 Shutdown
Fa0/2 1 0 0 Shutdown
Fa0/3 1 0 0 Shutdown
Fa0/4 1 0 0 Shutdown
Fa0/5 1 0 0 Shutdown
Fa0/6 1 0 0 Shutdown
--------------------------------------------------------------------------
To check port security status of a specific ports of switch.
switch> enable
switch # show port-security interface fa0/1
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disable
Maximum MAC Addresses : 1
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address: VLAN : 0000.0000.0000:0
Security Violation Count : 0
SECURE MAC ADDRESS LEARNING
The process of securing a MAC address is called learning. There are three method of MAC address learning. They are:1. Static
2. Dynamic
3. Sticky
Static: The static learning method allows you to manually add or remove MAC address in the mac-address-table. These MAC addresses are stored in the address table and in the running configuration of the switch.
Dynamic: In dynamic learning, switch learns MAC address dynamically and stores in its MAC address table. They are removed from the configuration when the switch restarts.
Sticky: – like Dynamic secure MAC addresses, MAC addresses are learned dynamically but are saved in the running configuration.
Note: default mode of learning is Dynamic.
switch> enable
switch # show mac-address-table
Mac Address Table
------------------------------------------------
Vlan MAC Address Type Ports
----- -------------- ------- --------
1 0030.a3e1.a590 DYNAMIC Fa0/1
1 00d0.97d8.895a DYNAMIC Fa0/2
------------------------------------------------
We can change DYNAMIC mode in static or Sticky
sw> enable
sw# config t
sw(config) # interface fa0/1
sw(config-if) # switchport port-security mac-address static 0030.a3e1.a590 (for static)
sw(config-if) # switchport port-security mac-address sticky (for sticky)
switch # show mac-address-table
Mac Address Table
------------------------------------------------
Vlan MAC Address Type Ports
----- -------------- ------- --------
1 0030.a3e1.a590 DYNAMIC Fa0/1
1 00d0.97d8.895a DYNAMIC Fa0/2
------------------------------------------------
We can change DYNAMIC mode in static or Sticky
sw> enable
sw# config t
sw(config) # interface fa0/1
sw(config-if) # switchport port-security mac-address static 0030.a3e1.a590 (for static)
sw(config-if) # switchport port-security mac-address sticky (for sticky)
MAXIMUM MAC ADDRESSES LIMIT FOR A SINGLE PORT
According to requirement we can hosts limit that can be associated with an interface. We can set this limit anywhere from 1 to 132. This may be depends on router`s series but default is 1.
To show maximum mac addresses limit
switch> enable
switch # show port-security interface fa0/1
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disable
Maximum MAC Addresses : 1
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address: VLAN : 0000.0000.0000:0
Security Violation Count : 0
To change maximum mac addresses limit
switch> enable
switch# conf t
switch (config) # interface fa0/1
switch (config-if) # switchport port-security maximum ?
<1 - 132 >
switch (config-if) # switchport port-security maximum 2
For Verification
switch> enable
switch # show port-security interface fa0/1
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disable
Maximum MAC Addresses : 2
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address: VLAN : 0000.0000.0000:0
Security Violation Count : 0
switch (config-if) # switchport port-security aging time 120
The time keyword specifies the aging time for this port. Valid range for aging time is 0 to 1440 minutes. Aging time 0 means that aging is disable on this port.
For absolute aging, all the secure addresses on this port ago out exactly after the specified aging time.
switch (config-if) # switchport port-security aging time 120 type inactivity
For inactive aging, all the secure address on this port ago out only if there is no data traffic from the secure source address for the specified time period.
Summary of Commands
switch> enable (to switch on privileged mode)
switch# config t (to switch on config mode)
switch(config)# interface fa0/1 (to select interface)
switch(config-if)# switchport mode access (to change interface in access mode)
switch(config-if)# switchport port-security
switch(config-if)# switchport port-security maximum 1 (mac-address-limit)
switch(config-if)# switchport port-security mac-address sticky (mac-address-learning)
switch(config-if)# switchport port-security violation protect (violation type)
switch(config-if)# end
switch# write (to save)
switch> enable
switch # show port-security interface fa0/1
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disable
Maximum MAC Addresses : 1
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address: VLAN : 0000.0000.0000:0
Security Violation Count : 0
To change maximum mac addresses limit
switch> enable
switch# conf t
switch (config) # interface fa0/1
switch (config-if) # switchport port-security maximum ?
<1 - 132 >
switch (config-if) # switchport port-security maximum 2
For Verification
switch> enable
switch # show port-security interface fa0/1
Port Security : Enabled
Port Status : Secure-up
Violation Mode : Shutdown
Aging Time : 0 mins
Aging Type : Absolute
SecureStatic Address Aging : Disable
Maximum MAC Addresses : 2
Total MAC Addresses : 0
Configured MAC Addresses : 0
Sticky MAC Addresses : 0
Last Source Address: VLAN : 0000.0000.0000:0
Security Violation Count : 0
PORT SECURITY VIOLATION
We need to specify what action; it should take in security violation. Three possible modes are available:
1. Protect
2. Restrict
3. Shutdown
Protect mode: This mode will work with sticky MAC address learning. In this mode frames from unknown address would be dropped. It will not make log entry for dropped frames.
Restrict mode: In restrict mode frames from unknown address would be dropped. But in this mode, switch will make a log entry and generate a security violation alert.
Shutdown mode: In this mode frames from unknown address would be dropped and switch will generate the violation alert and disable the port.
switch> enable
switch# conf t
switch (config) # interface fa0/1
switch# conf t
switch (config) # interface fa0/1
switch (config-if) # switchport port-security violation ?
Protect Security violation protect mode
restrict Security violation restrict mode
shutdown Security violation shutdown mode
PORT SECURITY AGING TIME
Using this feature we can set aging time and aging type
switch (config-if) # switchport port-security aging static
The static keyword enable aging for statically configured secure addresses on this port.
The time keyword specifies the aging time for this port. Valid range for aging time is 0 to 1440 minutes. Aging time 0 means that aging is disable on this port.
PORT SECURITY AGING TYPES
switch (config-if) # switchport port-security aging time 120 type absoluteFor absolute aging, all the secure addresses on this port ago out exactly after the specified aging time.
switch (config-if) # switchport port-security aging time 120 type inactivity
For inactive aging, all the secure address on this port ago out only if there is no data traffic from the secure source address for the specified time period.
POINTS TO BE REMEMBER
MAC Address Learning
1. Static
2. Dynamic
3. Sticky
Maximum MAC Address Limit
1. Range 1 to 132
2. Default
Port Security Violation
1. Protect
2. Restric
3. Shutdown
Port Security Aging Time
1. Static
2. Time in minutes (range is 0 to 1440)
3. 0 minute means disable aging time
Port Security Aging Types
1. Absolute
2. Inactivity
Summary of Commands
switch> enable (to switch on privileged mode)
switch# config t (to switch on config mode)
switch(config)# interface fa0/1 (to select interface)
switch(config-if)# switchport mode access (to change interface in access mode)
switch(config-if)# switchport port-security
switch(config-if)# switchport port-security maximum 1 (mac-address-limit)
switch(config-if)# switchport port-security mac-address sticky (mac-address-learning)
switch(config-if)# switchport port-security violation protect (violation type)
switch(config-if)# end
switch# write (to save)





