资源描述
实训一 交换机端口安全
1、 二层交换机端口安全
结论:离接入层越近风险越大,所以问题主要集中在接入层。
交换机主要面临4种攻击:
Ø MAC layer attacks
Ø VLAN attacks
Ø Spoofing attacks
Ø Attacks on switch devices
问题:如何防范这些攻击?
Cisco交换机上配置端口安全性的方法:
静态安全MAC地址:静态MAC地址是使用switchport port-security mac-address mac-address接口配置命令手动配置的。以此方法配置的MAC地址存储在地址表中,并添加到交换机的运行配置中。
动态安全MAC地址:动态MAC地址是动态获取的,并且仅存储在地址表中。以此方式配置的MAC地址在交换机重新启动时将被移除。
粘滞安全MAC地址:可以将端口配置为动态获得MAC地址,然后将这些MAC地址保存到运行配置中。
Switch(config-if)#switchport mode access
Switch(config-if)#switchport port-security
Switch(config-if)#switchport port-security mac-address 0090.2B1A.D48E
Switch(config-if)#switchport port-security violation ?
protect Security violation protect mode (不转发数据)
restrict Security violation restrict mode (不转发数据,上报网管平台)
shutdown Security violation shutdown mode (关闭接口,并上报网管平台)
Switch(config-if)#switchport port-security violation shutdown
验证:
测试结果
是否ping通
结论
PC0接Fa0/1接口上
PC0 ping PC1
否
PC1 ping PC0
否
PC3接Fa0/1接口上
PC1 ping PC3
是
PC3 ping PC1
否
查看交换机mac地址表:
Switch#show mac-address-table
查看端口安全的,以及每一个端口违反我们策略数
Switch#show port-security
绑定多个MAC地址:
Switch(config-if)#switchport port-security maximum ?
<1-132> Maximum addresses
Switch(config-if)#switchport port-security maximum 2
Switch(config-if)#switchport port-security mac-address 0009.7C65.1749
Switch#show mac-address-table
测试结果
是否ping通
结论
PC0接Fa0/1接口上
PC0 ping PC1
否
PC1 ping PC0
否
PC3接Fa0/1接口上
PC1 ping PC3
是
PC3 ping PC1
否
查看交换机mac地址表:
Switch#show mac-address-table
查看端口安全的,以及每一个端口违反我们策略数
Switch#show port-security
思考:若在PC0和交换机中间加入一台交换机或一台集线器,会发生什么问题?PC0和PC1之间,PC0和PC3之间可以相互通信吗?
答:PC0和PC1之间不可以相互通信;PC0和PC3之间可以相互通信。
说明:上面的端口绑定时静态指定来绑定,有没有动态绑定方法呢?
有
Switch(config)#interface fastEthernet 0/1
Switch(config-if)#switchport mode access
Switch(config-if)#switchport port-security
Switch(config-if)#switchport port-security mac-address sticky
在没有数据包发送情况下,查看交换机mac地址表,查看是否有数据?
Switch#show mac-address-table
答:有数据
思考:端口安全除了MAC地址绑定外,还有没有其他方法?
答:有
参考802.1x认证。
2、 三层交换机上
Arp命令实现IP地址与MAC地址绑定。
参考资料
cisco交换机端口的安全配置
一、switchport port-security
设置端口安全功能,端口安全的违例处理等。使用该命令的no选项关闭端口安全的设置,或者将安全违例处理方式恢复成缺省值。
switchport port-security [violation {protect | restrict | shutdown}]
no switchport port-security [violation]
参数说明
参数
描述
port-security
接口安全开关
violation protect
发现违例,则丢弃违例的报文。
violation restrict
发现违例,则丢弃违例的报文并且发送trap。
violation shutdown
发现违例,则丢弃报文、发送Trap并且关闭接口。
缺省配置
接口的安全缺省是关闭的。
命令模式
接口配置模式
使用指导
利用端口安全这个特性,可以通过限制允许访问设备上某个接口的MAC地址以及IP(可选)来实现严格控制对该接口的输入。当为安全端口(打开了端口安全功能的端口)配置了一些安全地址后,则除了源地址为这些安全地址的包外,这个端口将不转发其它任何报。此外,还可以限制一个端口上能包含的安全地址最大个数,如果将最大个数设置为1并且为该端口配置一个安全地址,则连接到这个口的工作站(其地址为配置的安全M地址)将独享该端口的全部带宽。
配置举例
下面的例子是在接口Gigabitethernet 1/1 上打开端口安全功能,并设置违例处理为shutdown:
Ruijie(config)# interface gigabitethernet1/1
Ruijie(config-if)# switchport port-security
Ruijie(config-if)# switchport port-security violation shutdown
二、 switchport port-security aging
该命令为一个接口上的所有安全地址配置老化时间。打开这个功能,就需要设置安全地址的最大个数,这样,就可以让设备自动的增加和删除接口上的安全地址。使用该命令的no选项设置老化时间只应用于自动学习的地址,或者关闭老化功能。
switchport port-security aging {static | time time }
no switchport port-security aging {static | time}
参数说明
参数
描述
Static
表示老化时间将同时应用于手工配置的安全地址和自动学习的地址,否则则只应用于自动学习的地址。
time time
表示这个端口上安全地址的老化时间,范围是0-1440,单位是分钟。如果设置为0,则老化功能实际上被关闭。
缺省配置
不老化任何安全地址
命令模式
接口配置模式
使用指导
可以在接口配置模式下使用命令no switchport port-security aging time关闭一个接口的安全地址老化功能,使用命令no switchport port-security aging static来是老化时间仅应用于动态学习到的安全地址。
使用show port-security命令查看设置。
配置举例
Ruijie(config)# interface gigabitethernet1/1
Ruijie(config-if)# switchport port-security aging time8
Ruijie(config-if)# switchport port-security aging static
相关命令
命令
描述
show port-security
显示端口安全的设置信息和安全地址。
三、switchport port-security maximum
设置端口最大安全地址个数,使用no选项可恢复缺省个数:
switchport port-security maximum value
[no] switchport port-security maximum
参数说明
参数
描述
value
安全地址个数1-128
缺省配置
128
命令模式
接口模式
使用指导
安全地址个数包含静态配置和动态学习的安全地址个数的总和,缺省为128个,如果设置的安全地址个数小于当前已有的安全地址个数,将提示设置失败
配置举例
例1:设置口10的端口安全地址个数为2:
Ruijie(config)#interg0/10
Ruijie(config-if)# switchport port-security maximum2
四、 switchport port-security mac-address
接口模式下手工配置静态安全地址,使用no选项删除配置的地址:
[no] switchport port-security mac-address mac-address[vlan vlan-id]
参数说明
参数
描述
mac-address
静态安全地址
vlan-id
MAC地址的VID
注意:仅在TRUNK口下才支持设置vlan-id的设置
缺省配置
无
命令模式
接口模式
配置举例
例1:设置TRUNK接口10的静态安全地址00d0.f800.5555 VID=2:
Ruijie(config)#inter g0/10
Ruijie(config-if)# switchport port-security mac-address00d0.f800.5555 vlan2
五、 show port-security
显示端口安全的设置信息和安全地址。
show port-security [address] [interfaceinterface-id] [all]
参数说明
参数
描述
address
显示所有的安全地址,或者是指定接口的所有安全地址。
interfaceinterface-id
显示指定接口的端口安全设置信息。
all
显示所有接口的端口安全设置信息。
命令模式
特权模式
使用指导
如果使用该命令时不加参数,则显示所有接口的安全设置状态、违例处理等信息,同时显示所有安全地址表的信息。
配置举例
Ruijie# show port-security
Secure Port MaxSecureAddr(count) CurrentAddr(count) Security Action
-------- -------------- ----------- -----------
Gi1/1 128 1 Restrict
Gi1/2 128 0 Restrict
Gi1/3 8 1 Protect
六、switchport protected
该命令是将接口设为保护接口。使用该命令的no选项关闭保护接口。
switchport protected
no switchport protected
缺省配置
缺省关闭保护接口
命令模式
接口配置模式
使用指导
当将某些端口设为保护口之后,缺省情况下保护口和保护口之间不能进行二层交换可以进行3层路由,保护口与非保护口之间可以正常通讯。使用show interfaces switchport命令查看设置。
配置举例
Switch(config)# interface gigabitethernet 1/1
Switch(config-if)# switchport protected
相关命令
命令
描述
show interfaces switchport
查看接口设置和统计信息。
展开阅读全文