目录
组网需求:
配置思路:
操作步骤:
配置文件:
组网需求:
 如 图 2-14 所示,用户网络 1 和用户网络 2 通过 LSW 与 Switch 相连, Switch 连接 LSW 的接口为GE0/0/1 。用户网络 1 和用户网络 2 分别属于 VLAN10 和 VLAN20 。在 Switch 上,为了控制接入用户数量,可以基于接口GE0/0/1 配置 MAC 地址学习限制功能。  
  
 配置思路:
 采用如下的思路配置基于接口的 MAC 地址学习限制:  
  1.  创建 VLAN ,并将接口加入到 VLAN 中,实现二层转发功能。  
  2.  配置基于接口的 MAC 地址学习限制,控制接入用户数量。 
 操作步骤:
 步骤 1  
  配置 MAC 地址学习限制  
  #  将 GigabitEthernet0/0/1 加入 VLAN10 和 VLAN20 。  
  <HUAWEI>  system-view  
  [HUAWEI]  sysname Switch  
  [Switch]  vlan batch 10 20  
  [Switch]  interface gigabitethernet 0/0/1  
  [Switch-GigabitEthernet0/0/1]  port link-type hybrid  
  [Switch-GigabitEthernet0/0/1]  port hybrid tagged vlan 10 20  
  #  在接口 GigabitEthernet0/0/1 上配置 MAC 地址学习限制规则:最多可以学习 100 个  
  MAC 地址,超过最大 MAC 地址学习数量的报文继续转发并进行告警提示。  
  [Switch-GigabitEthernet0/0/1]  mac-limit maximum 100 alarm enable  
  [Switch-GigabitEthernet0/0/1]  return  
  步骤 2  验证配置结果  
  #  在任意视图下执行 display mac-limit 命令,查看 MAC 地址学习限制规则是否配置成  
  功。  
  <Switch>  display mac-limit  
  MAC limit is enabled  
  Total MAC limit rule count : 1  
  PORT VLAN/VSI SLOT Maximum Rate(ms) Action Alarm  
  ----------------------------------------------------------------------------  
  GE0/0/1 - - 100 - discard enable  
  ---- 结束 
  配置文件:
 以下仅给出 Switch 的配置文件。  
  #  
  sysname Switch  
  #  
  vlan batch 10 20  
  #  
  interface GigabitEthernet0/0/1  
  port link-type hybrid  
  port hybrid tagged vlan 10 20  
  mac-limit maximum 100  
  #  
  return