华为交换机开机后接口等一直闪_交换机基础端口安全实战,原来可以这么玩,一分钟了解下...

1、实战目的

通过本实验,掌握如下技能:

(1) 理解交换机的 MAC 表

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

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

2. 拓扑

2daca621cd3bb6c8db75aaf592b56368.png

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

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

以下是华为数通路由交换方向完整技术分享,欢迎对华为网络技术感兴趣的小伙伴们订阅。

【可点击头像在专栏中进行查看订阅】

华为新版HCIA数通路由交换

华为新版HCIP数通路由交换

华为新版HCIE数通路由交换

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值