配置采用RADIUS协议进行认证和计费示例
组网需求
如图1-19所示,用户同处于huawei域,Switch作为目的网络接入服务器。用户需要通过服务器的远端认证才能通过Switch访问目的网络。在Switch上的远端认证方式如下:
Switch对接入用户先用RADIUS服务器进行认证,如果认证没有响应,再使用本地认证。
RADIUS服务器10.7.66.66/24作为主用认证服务器和计费服务器,RADIUS服务器10.7.66.67/24作为备用认证服务器和计费服务器,认证端口号缺省为1812,计费端口号缺省为1813。
操作步骤
- 配置RADIUS服务器模板。
# 配置RADIUS服务器模板shiva。
<HUAWEI> system-view [HUAWEI] sysname Switch [Switch] radius-server template shiva
# 配置RADIUS主用认证服务器和计费服务器的IP地址、端口。
[Switch-radius-shiva] radius-server authentication 10.7.66.66 1812 weight 80 [Switch-radius-shiva] radius-server accounting 10.7.66.66 1813 weight 80
# 配置RADIUS备用认证服务器和计费服务器的IP地址、端口。
[Switch-radius-shiva] radius-server authentication 10.7.66.67 1812 weight 40 [Switch-radius-shiva] radius-server accounting 10.7.66.67 1813 weight 40
# 配置RADIUS服务器密钥、重传次数,以及设备向RADIUS服务器发送的报文中的用户名不包含域名。
请确保RADIUS服务器模板内的共享密钥和RADIUS服务器上的配置保持一致。
[Switch-radius-shiva] radius-server shared-key cipher Huawei@2012 [Switch-radius-shiva] radius-server retransmit 2 [Switch-radius-shiva] undo radius-server user-name domain-included [Switch-radius-shiva] quit
- 配置认证方案、计费方案。
# 配置认证方案auth,认证模式为先进行RADIUS认证,后进行本地认证。
[Switch] aaa [Switch-aaa] authentication-scheme auth [Switch-aaa-authen-auth] authentication-mode radius local [Switch-aaa-authen-auth] quit
# 配置计费方案abc,计费模式为RADIUS,并配置当开始计费失败时,允许用户上线。
[Switch-aaa] accounting-scheme abc [Switch-aaa-accounting-abc] accounting-mode radius [Switch-aaa-accounting-abc] accounting start-fail online [Switch-aaa-accounting-abc] quit
- 配置huawei域,在域下应用认证方案auth、计费方案abc、RADIUS服务器模板shiva。
[Switch-aaa] domain huawei [Switch-aaa-domain-huawei] authentication-scheme auth [Switch-aaa-domain-huawei] accounting-scheme abc [Switch-aaa-domain-huawei] radius-server shiva [Switch-aaa-domain-huawei] quit [Switch-aaa] quit [Switch] quit
在huawei域配置完成后,用户进行接入认证时,以格式“user@huawei”输入用户名即可在huawei域下进行aaa认证。如果用户名中不携带域名或携带的域名不存在,用户将会在默认域进行认证。
用户所属认证域是由接入设备(RADIUS客户端)而非RADIUS Server决定。在Switch上执行命令undo radius-server user-name domain-included后,当Switch接收到格式为“user@huawei”的用户名时,虽然Switch会把不带域名的用户名发送到RADIUS Server,但Switch仍会将用户置于huawei域中进行认证。
- 配置AAA本地认证。
[Switch] aaa [Switch-aaa] local-user user1 password irreversible-cipher Huawei@123 [Switch-aaa] local-user user1 service-type http [Switch-aaa] local-user user1 privilege level 15 [Switch-aaa] quit
- 验证配置结果。
# 在Switch上执行命令display radius-server configuration template template-name,可以观察到该RADIUS服务器模板的配置与要求一致。
<Switch> display radius-server configuration template shiva ------------------------------------------------------------------------------ Server-template-name : shiva Protocol-version : standard Traffic-unit : B Shared-secret-key : %@%@BS'$!w:u7H.lu:/&W9A5=pUt%@%@ Timeout-interval(in second) : 5 Retransmission : 2 EndPacketSendTime : 0 Dead time(in minute) : 5 Domain-included : NO NAS-IP-Address : 0.0.0.0 Calling-station-id MAC-format : xxxx-xxxx-xxxx NAS-IPv6-Address : :: Server algorithm : master-backup Authentication Server 1 : 10.7.66.66 Port:1812 Weight:80 Vrf:- LoopBack:NULL Source IP: :: Authentication Server 2 : 10.7.66.67 Port:1812 Weight:40 Vrf:- LoopBack:NULL Source IP: :: Accounting Server 1 : 10.7.66.66 Port:1813 Weight:80 Vrf:- LoopBack:NULL Source IP: :: Accounting Server 2 : 10.7.66.67 Port:1813 Weight:40 Vrf:- LoopBack:NULL Source IP: :: ------------------------------------------------------------------------------
配置文件
Switch的配置文件
# sysname Switch # radius-server template shiva radius-server shared-key cipher %@%@BS'$!w:u7H.lu:/&W9A5=pUt%@%@ radius-server authentication 10.7.66.66 1812 weight 80 radius-server authentication 10.7.66.67 1812 weight 40 radius-server accounting 10.7.66.66 1813 weight 80 radius-server accounting 10.7.66.67 1813 weight 40 radius-server retransmit 2 undo radius-server user-name domain-included # aaa authentication-scheme auth authentication-mode radius local accounting-scheme abc accounting-mode radius accounting start-fail online domain huawei authentication-scheme auth accounting-scheme abc radius-server shiva local-user user1 password irreversible-cipher %@%@iv-e(@1]P90{2*&tcll)JN*KQ9c`"Ob^#"Al|p7EHK>qVzB%(7On,d&6iweF%@%@ local-user user1 privilege level 15 local-user user1 service-type http # return