实验十九、配置 MAC地址表实现绑定和过滤

一、 实验目的

1、了解 MAC 地址表在交换机中的作用;

2、熟练掌握如何配置 MAC地址表实现 MAC 与端口绑定功能。

二、 应用环境

1、通常交换机支持动态学习 MAC 地址的功能,每个端口可以动态学习多个 MAC 地址,从而实现端口之间已知 MAC 地址数据流的转发。当 MAC 地址老化后,则进行广播处理。也就是说,交换机某接口上学习到某 MAC地址后可以进行转发,如果将连线切 换到另外一个接口上交换机将重新学习该 MAC地址,从而在新切换的接口上实现数 据转发。

2、为了安全和便于管理,需要将 MAC地址与端口进行绑定,通过配置 MAC 地址表的方式进行绑定。即,MAC 地址与端口绑定后,该 MAC 地址的数据流只能从绑定端口进入,不能从其他端口进入。但是不影响其他 MAC 的数据流从该端口进入。

三、 实验设备

1、DCS-3926S 交换机 1 台

2、PC机 2 台

3、Console 线1根

4、直通网线 2根

四、 实验拓扑

clip_image002

五、 实验要求

1、交换机 IP 地址为 192.168.1.11/24,PC1 的地址为192.168.1.101/24;PC1的地址

为 192.168.1.102/24;

2、在交换机上作 MAC 与端口绑定;

3、PC1 在不同的端口上 ping 交换机的 IP,检验理论是否和实验一致;

4、PC1 在不同的端口上 ping 交换机的 IP,检验理论是否和实验一致。 六、 实验步骤

第一步:得到PC1机的MAC地址

Microsoft Windows XP [版本 5.1.2600]

(C) 版权所有 1985-2001 Microsoft Corp.

C:\>ipconfig/all

Windows IP Configuration

Host Name . . . . . . . . . . . . : xuxp

Primary Dns Suffix . . . . . . . : digitalchina.com

Node Type . . . . . . . . . . . . : Broadcast

IP Routing Enabled. . . . . . . . : No

WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter 本地连接:

Connection-specific DNS Suffix . :

Description . . . . . . . . . . . : Intel(R) PRO/100 VE Network Connecti

on

Physical Address. . . . . . . . . : 00-A0-D1-D1-07-FF

Dhcp Enabled. . . . . . . . . . . : Yes

Autoconfiguration Enabled . . . . : Yes

Autoconfiguration IP Address. . . : 169.254.27.232

Subnet Mask . . . . . . . . . . . : 255.255.0.0

Default Gateway . . . . . . . . . :

C:\>

我们得到了PC机的mac地址为:00-A0-D1-D1-07-FF。

第二步:交换机全部恢复出厂设置,给交换机设置地址

switch(Config)#int v 1

switch(Config-If-Vlan1)#ip address 192.168.1.11 255.255.255.0

switch(Config-If-Vlan1)#no shut

switch(Config-If-Vlan1)#exit

switch(Config)#

第三步:使用mac地址表配置来绑定。

switch(Config)#mac-address-table static address 00-a0-d1-d1-07-ff vlan 1

interface ethernet 0/0/1

switch(Config)#

验证测试:

switch#show mac-address-table

Read mac address table....

Vlan Mac Address Type Creator Ports

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

1 00-03-0f-01-7d-b1 STATIC System CPU

1 00-a0-d1-d1-07-ff STATIC User Ethernet0/0/1

switch#

第四步:ping命令测试

PC 端口 Ping 结果 原因

PC1 0/0/1 192.168.1.11 通

PC1 0/0/7 192.168.1.11 不通

PC2 0/0/1 192.168.1.11 通

PC2 0/0/7 192.168.1.11 通

第四步:将PC2网线连接在0/0/1上显示

switch#show mac-address-table

Read mac address table....

Vlan Mac Address Type Creator Ports

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

1 00-03-0f-01-7d-b1 STATIC System CPU

1 00-14-38-1d-ba-01 DYNAMIC Hardware Ethernet0/0/1

1 00-a0-d1-d1-07-ff STATIC User Ethernet0/0/1

switch#

第五步:配置MAC地址过滤

switch(Config)#mac-address-table blackhole address 00-a0-d1-d1-07-ff vlan 1

验证配置:

switch#show mac-address-table

Read mac address table....

Vlan Mac Address Type Creator Ports

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

1 00-03-0f-01-7d-b1 STATIC System CPU

1 00-a0-d1-d1-07-ff STATIC User (blackhole)

switch#

第六步:用ping命令验证

无论PC1插在交换机的哪个RJ45口上,都ping不通192.168.1.11

而PC2则能ping通。