以太网mac地址唯一地标识了世界上的每个以太网设备。每一个生产网络设备的厂商都要将mac地址预先写进其设备中(如:以太网网卡,路由器,交换机等)。各种媒体已有很多文章介绍获得mac地址的方法。今天我们主要讨论怎样在cisco的ios获得、改变mac地址,并使用mac地址进行网络通信过滤。
F i0GknQ+ 1YH+d0UGn >p"c>V& 8 获得mac地址
#'y#"cmQ. Mxv;k%l|E| 在交换机的命令输入窗口,输入“show mac-address-table”可以获得mac地址表,例如:
0=?<y'= - switch# show mac-address-table
- mac address table
- -------------------------------------------
- vlan mac address type ports
- ---- ----------- -------- -----
- all 0014.1c40.b080 static cpu
- all 0100.0ccc.cccc static cpu
- all 0100.0ccc.cccd static cpu
- all 0100.0cdd.dddd static cpu
- 1 000f.1fd3.d85a dynamic fa0/14
-
>rf'-X4n Y=Kc'x[,Zj 在思科路由器上,可以使用“show interfaces”来查看mac地址。例如:
Oeok; : - routerb# show interfaces
- ethernet0/0 is up, line protocol is up
- hardware is amdp2, address is 0003.e39b.9220 (bia 0003.e39b.9220)
- internet address is 1.1.1.1/8
sIy^m}02 MjU6/pO}L [EKQR>s) 在第二行,可以看到:“bia 0003.e39b.9220”,bia即“烧录地址”(burned in address),mac地址即0003.e39b.9220。
Om5Y|v"* ajEjZ6 改变mac地址
adR)Uq9 maNl^i -[wGX}} 改变mac地址实质上其否定含义就是mac欺骗。特别是对于无线网络的攻击,改变mac地址是常用的方法。改变mac地址也可以用于合法的用途,如测试mac过滤。
P(f0R8BE 6}!#;@D~ Ck)*& 要改变设备在路由器上的mac地址,需在interface configuration mode(界面配置模式)下,使用“mac –地址”命令。例如:
hbY5l}\5 - routerb# conf t
- enter configuration commands, one per line. end with cntl/z.
- routerb(config)# int e0/0
- routerb(config-if)# mac-address 0000.0000.0001
- routerb(config-if)#^z
- routerb#
- routerb# show int e0/0
- ethernet0/0 is up, line protocol is up
- hardware is amdp2, address is 0000.0000.0001 (bia 0003.e39b.9220)
- internet address is 1.1.1.1/8
Kkm>e{0)AY H["`Mn7j2 c_4[e5z 在改变mac地址以后,可以使用show interface命令来查看新的地址。
yjF1}SQ GU( _ 基于mac地址的通信过滤
0|{u{w@!` a m|F?|1 bAx-"Lu 通过协议分析仪,可以发现一些网络中某些设备非正常的数据通信。例如,某设备通过多个ip地址发送数据包。
,)vDeU zdYy^8V|z 这种情况,可以使用show mac-address-table命令来查看它所使用的交换机端口,并可以关闭此端口。但是,如果此端口连接的是一个集线器,而集线器又连接了许多其它设备那该怎么办呢?
vzim<;i &B6Ep6QS 有一个方法便是使用mac地址过滤来对路由器或交换机的数据通信进行过滤。下面是一个例子:
4b98KsYg ;)D];u|_ - cat3750switch(config)# mac access-list ext filtermac
- cat3750switch(config-ext-macl)# deny host 0000.0000.0001 any
- cat3750switch(config-ext-macl)# permit any any
- cat3750switch(config-ext-macl)# exit
- cat3750switch(config)# int g1/0/40
- cat3750switch(config-if)# mac access-group filtermac in
e,W%uH>X tp6 3@L|Q ur:3W6ZKl 此命令在cisco catalyst 3750 gigabit ethernet switch交换机上完成。我们创建了一个名为“filtermac”的acl(访问控制表)。这个acl拒绝了与源地址为0000.0000.0001(十六进制非二进制)的所有数据通信,但是却允许其它地址的数据通信。将这个acl运用到界面1/0/40,这就防止了拥有这个mac地址的设备与本端口的数据通信,而不管它的ip地址是什么。
n[lJLm^(_C 但是,不管怎么说,mac地址过滤并非安全措施,因为他人可以轻易地改变mac地址。
lPw%ErG K/IWH[