您的位置:首页 > 其它

交换机端口安全

2011-07-22 12:19 190 查看
交换机端口安全

1. 实验目的

通过本实验,读者可以掌握如下技能:

(1) 理解交换机的MAC 表

(2) 理解交换机的端口安全

(3) 配置交换机的端口安全特性

2. 实验拓扑

图12-3 实验2 拓扑图

3. 实验步骤

交换机端口安全特性,可以让我们配置交换机端口,使得非法的MAC 地址的设备接入时,

交换机自动关闭接口或者拒绝非法设备接入,也可以限制某个端口上最大的MAC 地址数。我

们这里限制f0/1 接口只允许R1 接入。

(1) 步骤1:检查R1 的g0/0 接口的MAC 地址

R1(config)#int g0/0

R1(config-if)#no shutdown

R1(config-if)#ip address 172.16.0.101 255.255.0.0

R1#show int g0/0

GigabitEthernet0/0 is up, line protocol is up

Hardware is MV96340 Ethernet, address is 0019.5535.b828 (bia 0019.5535.b828)

//这里可以看到g0/0 接口的MAC 地址,记下它

Internet address is 172.16.0.101/16

MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

(此处省略)

(2) 步骤2:配置交换机端口安全

S1(config)#int f0/1

S1(config-if)#shutdown

S1(config-if)#switch mode access

//以上命令把端口改为访问模式,即用来接入计算机,在下一章详细介绍该命令的含义。

S1(config-if)#switch port-securitiy

//以上命令是打开交换机的端口安全功能。

S1(config-if)#switch port-securitiy maximum 1

//以上命令只允许该端口下的MAC 条目最大数量为1,即只允许一个设备接入

S1(config-if)#switch port-securitiy violation { protect | shutdown | restrict }

􀁺 protect:当新的计算机接入时,如果该接口的MAC 条目超过最大数量,则这个新的计算

机将无法接入,而原有的计算机不受影响

􀁺 shutdown:当新的计算机接入时,如果该接口的MAC 条目超过最大数量,则该接口将会

被关闭,则这个新的计算机和原有的计算机都无法接入,需要管理员使用“no shutdown”

命令重新打开。

􀁺 restrict:当新的计算机接入时,如果该接口的MAC 条目超过最大数量,则这个新的计

算机可以接入,然而交换机将向发送警告信息。

S1(config-if)#switchport port-security mac-address 0019.5535.b828

//允许R1 路由器从f0/1 接口接入

S1(config-if)#no shutdown

S1(config)#int vlan1

S1(config-if)#no shutdown

S1(config-if)#ip address 172.16.0.1 255.255.0.0

//以上配置交换机的管理地址

(3) 步骤3:检查MAC 地址表

S1#show mac-address-table

Mac Address Table

-------------------------------------------

(此处省略)

Vlan Mac Address Type Ports

---- ----------- -------- -----

All 0100.0ccc.cccc STATIC CPU

1 0018.ba11.eb91 DYNAMIC Fa0/15

1 0019.5535.b828 STATIC Fa0/1

Total Mac Addresses for this criterion: 24

//R1 的MAC 已经被登记在f0/1 接口,并且表明是静态加入的

(4) 步骤4:模拟非法接入

这时从R1 ping 交换机的管理地址,可以ping 通,如下:

R1#ping 172.16.0.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.0.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms

在R1 上修改g0/0 的MAC 地址为另一个地址,模拟是另外一台设备接入。如下:

R1(config)#int g0/0

R1(config-if)#mac-address 12.12.12

几秒钟后,则在S1 上,出现:

01:09:39: %PM-4-ERR_DISABLE: psecure-violation error detected on Fa0/1, putting Fa0/1 in

err-disable state

01:09:39: %PORT_SECURITY-2-PSECURE_VIOLATION: Security violation occurred, caused by MAC address

0012.0012.0012 on port FastEthernet0/1.

01:09:40: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to down

//以上提示f0/1 接口被关闭

S1#show int f0/1

FastEthernet0/1 is down, line protocol is down (err-disabled)

Hardware is Fast Ethernet, address is 0018.ba11.f503 (bia 0018.ba11.f503)

MTU 1500 bytes, BW 100000 Kbit, DLY 100 usec,

reliability 255/255, txload 1/255, rxload 1/255

//以上表明f0/1 接口因为错误而被关闭。非法设备移除后,在f0/1 接口下,执行“shutdown”

和“no shutdown”命令可以重新打开该接口。

4. 实验调试

S1#show port-security

Secure Port MaxSecureAddr CurrentAddr SecurityViolation Security Action

(Count) (Count) (Count)

---------------------------------------------------------------------------

Fa0/1 1 1 0 Shutdown

---------------------------------------------------------------------------

Total Addresses in System (excluding one mac per port) : 0

Max Addresses limit in System (excluding one mac per port) : 6272

//以上可以查看端口安全的设置情况

12.4 实验3:交换机的密码恢复

1. 实验目的

通过本实验,读者可以掌握如下技能:

(1) 交换机的密码恢复步骤

2. 实验拓扑

如图12-2。

3.Total Addresses in System (excluding one mac per port) : 0

Max Addresses limit in System (excluding one mac per port) : 6272

//以上可以查看端口安全的设置情况
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: