Cisco2960交换机端口安全Port-Security

简介:

前两天机房一台Cisco2960的上联口经常down,当时让机房重启交换机也没用,后来让换了个口就恢复,但是过一段时间端口有会down,网上查了下可能是由于Cisco交换机的Port-Security导致端口down掉,后来去机房连接交换机查看了下,G17口显示err-disabled,为了确认是port-security的原因,我把它设置成恢复添加环路,30秒自动恢复,后来发先down后大概30秒G17就自动起来了

1
2
3
4
5
6
7
Switch#show interfaces status err-disabled 
Port      Name               Status         Reason              Err-disabled Vlans
Gi0/17                       err-disabled   loopback
Switch#configure terminal 
Switch(config)#errdisable recovery cause loopback   //err-disabled端口恢复添加环路这一项
Switch(config)#errdisable recovery interval 30    //配置超时时间30秒  
Switch(config)#

如果没有配置超时恢复功能,或者想在超时之前使端口恢复正常,则需要在端口上shutdown和noshutdown,这样才能让端口恢复到forwarding正常状态。重新查看处于err-disabled状态的端口,没有发现处于此状态的端口,G17状态也恢复了

1
2
3
4
5
Switch(config) #interface gigabitEthernet 0/17
Switch(config- if ) #shutdown 
Switch(config- if ) #no shutdown 
Switch #show interfaces gigabitEthernet 0/17
GigabitEthernet0 /17  is down, line protocol is down (notconnect)

为了防止后面再次down,我将交换机上Port-Security功能直接关闭掉

1
2
3
4
5
6
7
8
9
Switch #configure terminal 
Switch(config) #interface range gigabitEthernet 0/1 - 17
Switch(config- if -range) #switchport mode access 
Switch(config- if -range) #no switchport port-security 
Switch(config- if -range) #end
Switch #wr
Building configuration...
[OK]
Switch #


思科交换机端口安全(Port-Security)简介


防止MAC地址泛洪攻击,如果检测到非法流量(白名单地址满了),接口的安全缺省是关闭的。

开启端口安全功能

switchport port-security [violation {protect | restrict | shutdown}] 

参数说明

switchport port-security violation shutdown //违规后执行动作shutdown(err-disable),默认执行策略就是把端口err-disable掉

switchport port-security violation protect  //将违规的mac地址的流量丢弃,不记录

switchport port-security violation restrict //将违规的mac地址的流量丢弃,并向SNMP发送一个违规日志

eg:

单个端口操作

SW2(config)#int f0/2

SW2(config-if)#switchport port-security //开启端口安全

Command rejected: FastEthernet0/2 is a dynamic port  dynamic port不能启用Port Security,只有静态接入端口或中继端口才行。要将模式切换为access。动态端口是自动识别的,既可以为access,也可以为trunk,所以要设为access

SW2(config-if)#switchport mode access //开启端口安全前,端口模式必须为接入模式

SW2(config-if)#switchport port-security 

SW2(config-if)#switchport port-security violation shutdown 

SW2(config-if)#switchport port-security maximum 100 /允许此端口通过的最大MAC地址数目为100。默认最大允许的安全MAC地址数量1

SW2(config-if)#switchport port-security mac-address sticky/开启MAC白名单地址地址粘贴

SW2(config-if)#switchport port-security mac-address sticky 000C.8543.0A81 /粘贴MAC地址

Switch(config)#errdisable recovery cause psecure-violation /恢复,或者你可以手动的shut再no shut端口。


多端口操作

Switch(config)#interface range gigabitEthernet 0/3 - 6

Switch(config-if-range)#switchport mode access

SW2(config-if)#switchport port-security violation protect

SW2(config-if)#switchport port-security violation restrict


被惩罚后进入err-disable的恢复:

如果一个psec端口由于被惩罚进入了err-disable,可以使用如下方法来恢复接口的状态:

  • 使用全局配置命令:err-disable recovery psecure-violation 

  • 手工将特定的端口shutdown再noshutdown


关闭端口安全功能

SW2(config)#int f0/2

SW2(config-if)#no switchport port-security /关闭端口安全

Switch(config-if)#exit

Switch(config)#interface range gigabitEthernet 0/3 - 6

Switch(config-if-range)#no switchport port-security 



本文转自 justin_peng 51CTO博客,原文链接:http://blog.51cto.com/ityunwei2017/1733122,如需转载请自行联系原作者

相关文章
|
7月前
|
网络架构
交换机与路由器技术-36-端口镜像
交换机与路由器技术-36-端口镜像
35 0
|
4月前
|
安全 Linux 网络安全
Linux【安全 01】云服务器主机安全加固(修改SSHD端口、禁用登陆失败的IP地址、使用密钥登录)
Linux【安全 01】云服务器主机安全加固(修改SSHD端口、禁用登陆失败的IP地址、使用密钥登录)
183 1
|
4月前
|
安全 网络协议 Unix
端口和安全
端口和安全
|
6月前
|
存储 网络协议 分布式数据库
网络名词术语解析 | 路由、交换机、集线器、半/全双工、DNS、LAN、WAN、端口、MTU
网络名词术语解析 | 路由、交换机、集线器、半/全双工、DNS、LAN、WAN、端口、MTU
153 0
|
9月前
|
安全
ERR_UNSAFE_PORT , Chromium 的默认非安全端口
ERR_UNSAFE_PORT , Chromium 的默认非安全端口
90 0
|
11月前
|
弹性计算 网络协议 安全
阿里云ECS云服务器安全组设置开放端口教程
阿里云ECS云服务器安全组设置开放端口教程,阿里云服务器端口怎么打开?云服务器ECS端口在安全组中开启,轻量应用服务器端口在防火墙中打开,阿里云服务器网以80端口为例,来详细说下阿里云服务器端口开放图文教程,其他的端口如8080、3306、443、1433也是同样的方法进行开启端口:
1583 0
|
11月前
|
弹性计算 网络协议 安全
阿里云服务器开放端口教程(通过配置安全组规则)
阿里云服务器开放端口教程(通过配置安全组规则)阿里云服务器端口怎么打开?云服务器ECS端口在安全组中开启,轻量应用服务器端口在防火墙中打开,阿里云服务器网以80端口为例,来详细说下阿里云服务器端口开放图文教程,其他的端口如8080、3306、443、1433也是同样的方法进行开启端口:
1180 0
|
11月前
|
弹性计算 网络协议 安全
阿里云ECS云服务器安全组配置开放端口方法教程
阿里云ECS云服务器安全组配置开放端口方法教程,阿里云服务器端口怎么打开?云服务器ECS端口在安全组中开启,轻量应用服务器端口在防火墙中打开,阿里云服务器网以80端口为例,来详细说下阿里云服务器端口开放图文教程,其他的端口如8080、3306、443、1433也是同样的方法进行开启端口:
770 0
|
11月前
|
弹性计算 网络协议 安全
阿里云服务器80端口开启教程(安全组配置)
阿里云服务器80端口开启教程(安全组配置)阿里云服务器端口怎么打开?云服务器ECS端口在安全组中开启,轻量应用服务器端口在防火墙中打开,阿里云服务器网以80端口为例,来详细说下阿里云服务器端口开放图文教程,其他的端口如8080、3306、443、1433也是同样的方法进行开启端口:
1789 0
|
11月前
|
弹性计算 网络协议 安全
阿里云服务器开放端口教程(配置安全组规则)
阿里云服务器开放端口教程(配置安全组规则)阿里云服务器端口怎么打开?云服务器ECS端口在安全组中开启,轻量应用服务器端口在防火墙中打开,阿里云服务器网以80端口为例,来详细说下阿里云服务器端口开放图文教程,其他的端口如8080、3306、443、1433也是同样的方法进行开启端口:
673 0