12.3 实验2:交换机端口安全

 

1. 实验目的
通过本实验,读者可以掌握如下技能:
(1) 理解交换机的MAC 表
(2) 理解交换机的端口安全
(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,即只允许一个设备接入注意交换机也是有mac地址的,如果在一个交换机a上连另一个交换机b,之后在b上连电脑,则mac条目至少是2,否则电脑就根本上不去。
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-tableMac 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 state01: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
//以上可以查看端口安全的设置情况


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值