配置基于VLANIF接口的混合认证示例
组网需求
如图3-20所示,某公司内部大量用户终端通过Switch(作为接入设备)的接口GE0/0/1接入网络。为了更有效的管理用户,该公司决定控制用户接入网络,要求只有通过认证的用户才能接入网络。同时,考虑到用户终端的多样性以及用户终端均未安装认证客户端的情况,管理员需要部署基于VLANIF接口的混合认证方式对用户进行接入控制。
配置思路
采用如下思路配置混合认证:
- 创建并配置RADIUS服务器模板、AAA方案以及认证域,并在认证域下绑定RADIUS服务器模板与AAA方案。保证了Switch与RADIUS服务器之间的信息交互。
- 配置VLANIF接口下的MAC认证。
- 配置Portal认证。
配置本举例之前,需确保网络中各设备之间已能互通。
操作步骤
- 创建并配置RADIUS服务器模板、AAA认证方案以及认证域。
# 创建并配置RADIUS服务器模板“rd1”。
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] radius-server template rd1 [Switch-radius-rd1] radius-server authentication 192.168.2.30 1812 [Switch-radius-rd1] radius-server shared-key cipher Example@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@example.com,用户密码Example2012)
[Switch] test-aaa test@example.com Example2012 radius-template rd1 Info: Account test succeeded.
- 创建VLAN并配置接口允许通过的VLAN,保证网络通畅。
[Switch] vlan batch 10 20 [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.1 24 [Switch-Vlanif10] quit [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 [Switch] interface vlanif 20 [Switch-Vlanif10] ip address 192.168.2.1 24 [Switch-Vlanif10] quit
- 配置MAC认证。
# 将NAC配置模式切换成传统模式。
[Switch] undo authentication unified-mode Warning: Switching the authentication mode will take effect after system restart . Some configurations are invalid after the mode is switched. For the invalid co mmands, see the user manual. Save the configuration file and reboot now? [Y/N] y
- 缺省情况下,NAC配置模式为统一模式。
- 统一模式切换到传统模式后,管理员必须保存配置并重启设备,新配置模式的各项功能才能生效。
# 在全局和VLANIF接口下使能MAC认证。
<Switch> system-view [Switch] mac-authen [Switch] interface vlanif 10 [Switch-Vlanif10] mac-authen [Switch-Vlanif10] quit
- 配置Portal认证。
# 创建并配置名称为“abc”的Portal服务器模板。
[Switch] web-auth-server abc [Switch-web-auth-server-abc] server-ip 192.168.2.20 [Switch-web-auth-server-abc] port 50200 [Switch-web-auth-server-abc] url http://192.168.2.30:8080/webagent [Switch-web-auth-server-abc] quit
请确保设备配置的端口号与Portal服务器使用的端口号保持一致。
# 使能Portal认证功能。
[Switch] interface vlanif 10 [Switch-Vlanif10] web-auth-server abc direct [Switch-Vlanif10] quit
# 配置设备与Portal服务器信息交互的共享密钥为Example@123,并以密文形式显示。
[Switch] web-auth-server abc [Switch-web-auth-server-abc] shared-key cipher Example@123 [Switch-web-auth-server-abc] quit
# 配置允许接入的最大Portal认证用户数为100。
[Switch] portal max-user 100
# 配置Portal认证用户下线探测周期为500秒。[Switch] portal timer offline-detect 500
- 验证配置结果。
- 执行命令display mac-authen、display portal和display web-auth-server configuration能够查看到在接口VLANIF10上已使能了MAC认证以及Portal认证。
- 用户通过MAC认证或Portal认证中的任意一种即可接入网络。
- 用户上线后,管理员可在设备上执行命令display access-user查看接口下所有在线用户信息。
配置文件
Switch的配置文件
# sysname Switch # vlan batch 10 20 undo authentication unified-mode # domain isp1 # mac-authen # radius-server template rd1 radius-server shared-key cipher %^%#t67cDelRvAQg;*"4@P/3~q_31Sn{ST\V8'Ci633)%^%# radius-server authentication 192.168.2.30 1812 weight 80 # web-auth-server abc server-ip 192.168.2.20 port 50200 shared-key cipher %^%#t:hJ@gD7<+G&,"Y}Y[VP4\foQ&og/Gg(,J4#\!gD%^%# url http://192.168.2.30:8080/webagent # aaa authentication-scheme abc authentication-mode radius domain isp1 authentication-scheme abc radius-server rd1 # interface Vlanif10 ip address 192.168.1.1 255.255.255.0 web-auth-server abc direct mac-authen # interface Vlanif20 ip address 192.168.2.1 255.255.255.0 # interface GigabitEthernet0/0/1 port link-type access port default vlan 10 # interface GigabitEthernet0/0/2 port link-type access port default vlan 20 # portal max-user 100 portal timer offline-detect 500 # return