配置通过MAC认证控制企业内部用户访问网络示例
组网需求
如图2-11所示,某公司机要室内终端通过Switch接入公司内部网络。如果该公司内存在非法接入和非授权访问的状况,将会导致企业业务系统的破坏以及关键信息资产的泄露,因此管理员希望Switch能够对用户的网络访问权限进行控制,以保证公司内网的安全。
操作步骤
- 创建VLAN并配置接口允许通过的VLAN,保证网络通畅。
# 创建VLAN10、VLAN20。
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] vlan batch 10 20
# 配置Switch与用户连接的接口GE0/0/1为Access类型接口,并将其加入VLAN10。
[Switch] interface gigabitethernet 0/0/1 [Switch-GigabitEthernet0/0/1] port link-type access [Switch-GigabitEthernet0/0/1] port default vlan 10 [Switch-GigabitEthernet0/0/1] quit [Switch] interface vlanif 10 [Switch-Vlanif10] ip address 192.168.1.10 24 [Switch-Vlanif10] quit
设备与用户连接的接口类型与接口加入的VLAN应以用户实际所属VLAN为准,此处假设所有的用户都被划分到VLAN10。
# 配置Switch连接RADIUS服务器的接口GE0/0/2为Access类型接口,并将其加入VLAN20。
[Switch] interface gigabitethernet 0/0/2 [Switch-GigabitEthernet0/0/2] port link-type access [Switch-GigabitEthernet0/0/2] port default vlan 20 [Switch-GigabitEthernet0/0/2] quit
- 创建并配置RADIUS服务器模板、AAA认证方案以及认证域。
# 创建并配置RADIUS服务器模板“rd1”。
[Switch] radius-server template rd1 [Switch-radius-rd1] radius-server authentication 192.168.2.30 1812 [Switch-radius-rd1] radius-server shared-key cipher Huawei@2012 [Switch-radius-rd1] quit
# 创建AAA认证方案“abc”并配置认证方式为RADIUS。
[Switch] aaa [Switch-aaa] authentication-scheme abc [Switch-aaa-authen-abc] authentication-mode radius [Switch-aaa-authen-abc] quit
# 创建认证域“isp1”,并在其上绑定AAA认证方案“abc”与RADIUS服务器模板“rd1”。
[Switch-aaa] domain isp1 [Switch-aaa-domain-isp1] authentication-scheme abc [Switch-aaa-domain-isp1] radius-server rd1 [Switch-aaa-domain-isp1] quit [Switch-aaa] quit
# 配置全局默认域为“isp1”。用户进行接入认证时,以格式“user@isp1”输入用户名即可在isp1域下进行aaa认证。如果用户名中不携带域名或携带的域名不存在,用户将会在默认域中进行认证。
[Switch] domain isp1
# 测试用户是否能够通过RADIUS模板的认证。(已在RADIUS服务器上配置了测试用户test@huawei.com,用户密码Huawei2012)
[Switch] test-aaa test@huawei.com Huawei2012 radius-template rd1 Info: Account test succeed.
- 在Switch上配置MAC认证。
# 将NAC配置模式切换成统一模式。
[Switch] authentication unified-mode
# 在接口GE0/0/1上使能MAC认证。[Switch] interface gigabitethernet 0/0/1 [Switch-GigabitEthernet0/0/1] authentication mac-authen [Switch-GigabitEthernet0/0/1] authentication mode multi-authen max-user 100 [Switch-GigabitEthernet0/0/1] quit
# (推荐配置)配置指定VLAN内用户下线探测报文的源IP地址和源MAC地址。建议用户下线探测报文的源IP地址和源MAC地址配置为用户网关的IP地址和MAC地址。[Switch] access-user arp-detect vlan 10 ip-address 192.168.1.10 mac-address 2222-1111-1234
- 验证配置结果。
- 执行命令display mac-authen查看MAC认证的各项配置信息。从显示信息中能够看到接口GE0/0/1下已使能MAC认证(MAC address authentication is enabled)。
- 用户启动终端后,设备会自动获取用户终端的MAC地址作为用户名和密码进行认证。
- 用户认证成功后即可访问网络。
- 用户上线后,管理员可在设备上执行命令display access-user access-type mac-authen查看在线MAC认证用户信息。
配置文件
Switch的配置文件
# sysname Switch # vlan batch 10 20 # domain isp1 # access-user arp-detect vlan 10 ip-address 192.168.1.10 mac-address 2222-1111-1234 # radius-server template rd1 radius-server shared-key cipher %@%@BS'$!w:u7H.lu:/&W9A5=pUt%@%@ radius-server authentication 192.168.2.30 1812 weight 80 # aaa authentication-scheme abc authentication-mode radius domain isp1 authentication-scheme abc radius-server rd1 # interface Vlanif10 ip address 192.168.1.10 255.255.255.0 # interface GigabitEthernet0/0/1 port link-type access port default vlan 10 authentication mac-authen authentication mode multi-authen max-user 100 # interface GigabitEthernet0/0/2 port link-type access port default vlan 20 # return