配置外置Portal认证示例(使用HTTPS协议)
组网需求
如图2-64所示,某公司访客区内用户通过Switch接入公司内部网络。如果该公司内存在非法接入和非授权访问的状况,将会导致企业业务系统的破坏以及关键信息资产的泄露,因此管理员希望Switch能够对用户的网络访问权限进行控制,以保证公司内网的安全。
根据访客流动性大的特点,使用Portal认证并通过RADIUS服务器验证用户的身份。
操作步骤
- 配置网络互连互通。
# 创建VLAN并配置接口允许通过的VLAN、IP地址。
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] vlan batch 10 20 [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-Vlanif20] ip address 192.168.2.10 24 [Switch-Vlanif20] quit [Switch] interface gigabitethernet 0/0/1 [Switch-GigabitEthernet0/0/1] port link-type trunk [Switch-GigabitEthernet0/0/1] port trunk allow-pass vlan 10 [Switch-GigabitEthernet0/0/1] quit [Switch] interface vlanif 10 [Switch-Vlanif10] ip address 192.168.1.10 24 [Switch-Vlanif10] quit
- 配置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 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
# 创建认证域“example.com”,并在其上绑定AAA认证方案“abc”与RADIUS服务器模板“rd1”。
[Switch-aaa] domain example.com [Switch-aaa-domain-example.com] authentication-scheme abc [Switch-aaa-domain-example.com] radius-server rd1 [Switch-aaa-domain-example.com] quit [Switch-aaa] quit
# 测试用户是否能够通过RADIUS模板的认证。(已在RADIUS服务器上配置了测试用户test,用户密码Example2012)
[Switch] test-aaa test Example2012 radius-template rd1 Info: Account test succeeded.
- 配置Portal认证。# 将NAC配置模式切换成统一模式。
设备默认为统一模式。传统模式与统一模式相互切换后,设备会自动重启。
[Switch] authentication unified-mode
# 配置SSL策略。[Switch] ssl policy abcd [Switch-ssl-policy-abcd] certificate load pem-cert cert_rsa_cert.pem key-pair rsa key-file cert_rsa_key.pem auth-code cipher example [Switch-ssl-policy-abcd] ssl minimum version tls1.2 [Switch-ssl-policy-abcd] quit
为SSL策略加载证书时,需确保设备上已存在所需的证书文件和密钥对文件,否则加载不成功。另外,证书文件和密钥对文件必须保存在系统根目录下名为security的子目录下,如果没有security目录,则需要创建此目录。
# 开启HTTPS协议的Portal对接功能。[Switch] portal web-authen-server https ssl-policy abcd
# 配置Portal服务器模板“abc”。[Switch] web-auth-server abc [Switch-web-auth-server-abc] server-ip 192.168.2.30 [Switch-web-auth-server-abc] protocol http password-encrypt uam [Switch-web-auth-server-abc] http-method post cmd-key cmd1 [Switch-web-auth-server-abc] url https://192.168.2.30:8445/portal [Switch-web-auth-server-abc] quit
这里只配置命令http-method post中的cmd-key参数,其余解析POST请求报文的参数采用默认配置,但是这些参数必须与Portal服务器中的参数一致,否则会导致与Portal服务器对接失败。
# 配置Portal接入模板“web1”。[Switch] portal-access-profile name web1 [Switch-portal-acces-profile-web1] web-auth-server abc direct [Switch-portal-acces-profile-web1] quit
# 配置免认证规则模板。
[Switch] free-rule-template name default_free_rule [Switch-free-rule-default_free_rule] free-rule 1 destination ip 192.168.1.10 mask 24 [Switch-free-rule-default_free_rule] quit
# 配置认证模板“p1”,并在其上绑定Portal接入模板“web1”、绑定免认证规则模板“default_free_rule”、指定认证模板下用户的强制认证域为“example.com”、指定用户接入模式为多用户单独认证接入模式、最大接入用户数为100。
[Switch] authentication-profile name p1 [Switch-authen-profile-p1] portal-access-profile web1 [Switch-authen-profile-p1] free-rule-template default_free_rule [Switch-authen-profile-p1] access-domain example.com force [Switch-authen-profile-p1] authentication mode multi-authen max-user 100 [Switch-authen-profile-p1] quit
本举例中以用户采用静态分配IP地址方式为例。如果用户采用DHCP方式获取IP地址,并且DHCP服务器处于Switch的上行网络时,需要配置免认证规则放行DHCP服务器所在的网段。免认证规则的配置方法请参见配置用户免认证的授权信息。
# 在接口GE0/0/1上绑定认证模板“p1”,使能Portal认证。
[Switch] interface gigabitethernet 0/0/1 [Switch-GigabitEthernet0/0/1] authentication-profile p1 [Switch-GigabitEthernet0/0/1] quit
- 验证配置结果。
- 用户打开浏览器输入任意的网络地址后,将会被重定向到Portal认证页面。之后,用户可输入用户名和密码进行认证。
- 如果用户输入的用户名和密码验证正确,Portal认证页面会显示认证成功信息。用户即可访问网络。
- 用户上线后,管理员可在接入设备上执行命令display access-user access-type portal查看在线Portal认证用户信息。