员工满楼跑每次回WiFi都要重登?华为MAC优先Portal认证限时免重复输密码
Portal认证是很多公司管无线网的方式:终端一连上WiFi就自动弹出网页,输账号密码才能进内网,访客和员工都好管理。但它有个烦人的副作用——员工端着笔记本满楼跑,从会议室到车间再到仓库,每离开一次信号覆盖区再回来,网页又弹出来了,密码又得输一遍。一天输七八次,投诉就到了IT这里。华为官方文档对这个场景给的解法叫"MAC优先的Portal认证":首次连接时正常走Portal网页输账号密码,认证通过后设备记住这台终端,在一定时间内(如60分钟)因位置移动反复进入、离开无线信号覆盖区域时,不需要再输入用户名密码重新接入。本篇按官方示例原样走一遍,两台设备的命令都给全,照抄就能落。
组网需求(官方原文转述)
DeviceA提供随板AC功能,通过接入交换机DeviceB连接AP,通过无线网络部署,提供名为 wlan-net 的无线网络方便员工接入;DeviceA同时作为DHCP服务器,为无线用户提供10.23.101.0/24网段的IP地址。为了能实现在一定的时间内(如:60分钟)因位置移动而反复进入、离开无线信号覆盖区域时,不需要输入用户名密码重新接入,部署MAC优先的Portal认证。本例中Interface1、Interface2、Interface3分别代表10GE0/0/1、10GE0/0/2、10GE0/0/3。
数据规划(官方原表转述)
| 配置项 | 数据 |
|---|---|
| RADIUS认证参数 | 认证方案 radius_test;计费方案 scheme1;服务器模板 radius_test(IP 10.23.200.1,认证端口 1812,计费端口 1813,共享密钥 YsHsjx_202206mc@1) |
| Portal参数 | Portal接入模板 web1;Portal服务器模板 abc(服务器IP 10.23.200.1,协议 Portal协议,密钥 YsHsjx_202206,端口 50200) |
| 认证模板 | p1,绑定Portal接入模板 web1、RADIUS服务器模板 radius_test、RADIUS认证方案 radius_test、RADIUS计费方案 scheme1 |
| DHCP服务器 | DeviceA为STA和AP分配IP地址:AP地址池 VLANIF100 10.23.100.2~10.23.100.254/24,STA地址池 VLANIF101 10.23.101.2~10.23.101.254/24 |
| AC的源接口IP地址 | VLANIF100:10.23.100.1/24 |
| AP组 | ap-group1,绑定VAP模板 wlan-vap、域管理模板 domain1 |
| 域管理模板 | domain1,国家码 CN |
| SSID模板 | wlan-ssid,SSID名称 wlan-net |
| 安全模板 | wlan-security,安全策略 open |
| VAP模板 | wlan-vap,业务VLAN 101,绑定SSID模板、安全模板、做Portal认证的认证模板 p1 |
| 免认证规则模板 | default_free_rule,免认证资源:DNS服务器地址 10.23.202.1 |
第一步:接入交换机DeviceB(官方命令照抄)
把连接AP和上行口的三个口都放进管理VLAN100:
<HUAWEI> system-view
[HUAWEI] sysname DeviceB
[DeviceB] vlan batch 100
[DeviceB] interface 10ge 0/0/1
[DeviceB-10GE0/0/1] port link-type trunk
[DeviceB-10GE0/0/1] port trunk pvid vlan 100
[DeviceB-10GE0/0/1] port trunk allow-pass vlan 100
[DeviceB-10GE0/0/1] quit
[DeviceB] 10ge 0/0/2
[DeviceB-10GE0/0/2] port link-type trunk
[DeviceB-10GE0/0/2] port trunk pvid vlan 100
[DeviceB-10GE0/0/2] port trunk allow-pass vlan 100
[DeviceB-10GE0/0/2] quit
[DeviceB] interface 10ge 0/0/3
[DeviceB-10GE0/0/3] port link-type trunk
[DeviceB-10GE0/0/3] port trunk allow-pass vlan 100
[DeviceB-10GE0/0/3] quit
第二步:DeviceA连通、DHCP与认证源接口(官方命令照抄)
下行口进管理VLAN100,上行口进与RADIUS服务器互通的VLAN200:
[DeviceA] vlan batch 100 101 200
[DeviceA] interface 10ge 0/0/1
[DeviceA-10GE0/0/1] port link-type trunk
[DeviceA-10GE0/0/1] port trunk allow-pass vlan 100
[DeviceA-10GE0/0/1] quit
[DeviceA] interface 10ge 0/0/2
[DeviceA-10GE0/0/2] port link-type trunk
[DeviceA-10GE0/0/2] port trunk allow-pass vlan 200
[DeviceA-10GE0/0/2] quit
DHCP两个接口地址池,一个给AP、一个给无线终端:
[DeviceA] dhcp enable
[DeviceA] interface vlanif 100
[DeviceA-Vlanif100] ip address 10.23.100.1 24
[DeviceA-Vlanif100] dhcp select interface
[DeviceA-Vlanif100] quit
[DeviceA] interface vlanif 101
[DeviceA-Vlanif101] ip address 10.23.101.1 24
[DeviceA-Vlanif101] dhcp select interface
[DeviceA-Vlanif101] quit
VLANIF200单独给个IP,作为Portal认证的源接口:
[DeviceA] interface vlanif 200
[DeviceA-Vlanif200] ip address 10.23.200.3 24
[DeviceA-Vlanif200] quit
第三步:让AP上线(官方命令照抄)
创建AP组与域管理模板(国家码CN)并引用:
[DeviceA] wlan
[DeviceA-wlan] ap-group name ap-group1
[DeviceA-wlan-ap-group-ap-group1] quit
[DeviceA-wlan] regulatory-domain-profile name domain1
[DeviceA-wlan-regulate-domain-domain1] country-code cn
[DeviceA-wlan-regulate-domain-domain1] quit
[DeviceA-wlan] ap-group name ap-group1
[DeviceA-wlan-ap-group-ap-group1] regulatory-domain-profile domain1
[DeviceA-wlan-ap-group-ap-group1] quit
[DeviceA-wlan] quit
配置WAC源接口。官方示例先执行 capwap dtls no-auth enable(设备随后交互式要求设置DTLS PSK、FIT AP用户名密码等,按提示输入),再指定源接口:
[DeviceA] capwap dtls no-auth enable
[DeviceA] capwap source interface vlanif 100
离线导入AP(示例MAC 00e0-fc12-3456,部署在1号区域命名area_1;ap auth-mode缺省即MAC认证,未改过可不敲):
[DeviceA] wlan
[DeviceA-wlan] ap auth-mode mac-auth
[DeviceA-wlan] ap-id 0 ap-mac 00e0-fc12-3456
[DeviceA-wlan-ap-0] ap-name area_1
[DeviceA-wlan-ap-0] ap-group ap-group1
[DeviceA-wlan-ap-0] quit
[DeviceA-wlan] quit
AP正常上线后及时关闭DTLS不认证方式:
[DeviceA] undo capwap dtls no-auth enable
第四步:RADIUS与认证域(官方命令照抄)
请确保RADIUS服务器地址、端口号、共享密钥配置正确,并且和RADIUS服务器保持一致。
[DeviceA] radius-server template radius_test
[DeviceA-radius-radius_test] radius-server authentication 10.23.200.1 1812
[DeviceA-radius-radius_test] radius-server accounting 10.23.200.1 1813
[DeviceA-radius-radius_test] radius-server shared-key cipher YsHsjx_202206mc@1
[DeviceA-radius-radius_test] quit
[DeviceA] aaa
[DeviceA-aaa] authentication-scheme radius_test
[DeviceA-aaa-authen-radius_test] authentication-mode radius
[DeviceA-aaa-authen-radius_test] quit
[DeviceA-aaa] accounting-scheme scheme1
[DeviceA-aaa-accounting-scheme1] accounting-mode radius
[DeviceA-aaa-accounting-scheme1] accounting realtime 15
[DeviceA-aaa-accounting-scheme1] quit
[DeviceA-aaa] domain test
[DeviceA-aaa-domain-test] authentication-scheme radius_test
[DeviceA-aaa-domain-test] accounting-scheme scheme1
[DeviceA-aaa-domain-test] radius-server radius_test
[DeviceA-aaa-domain-test] quit
第五步:Portal服务器模板与接入模板(官方命令照抄)
Portal服务器模板定清楚:本端源地址(就是第二步VLANIF200那个IP)、服务器IP、端口、认证页面URL和密钥。URL在示例里是 http://10.23.200.1:8080/portal,实际部署换成你自己的Portal服务器地址:
[DeviceA] web-auth-server abc
[DeviceA-web-auth-server-abc] server-source ip-address 10.23.200.3
[DeviceA-web-auth-server-abc] server-ip 10.23.200.1
[DeviceA-web-auth-server-abc] port 50200
[DeviceA-web-auth-server-abc] url http://10.23.200.1:8080/portal
[DeviceA-web-auth-server-abc] shared-key cipher YsHsjx_202206
[DeviceA-web-auth-server-abc] quit
[DeviceA] portal-access-profile name web1
[DeviceA-portal-access-profile-web1] web-auth-server abc
[DeviceA-portal-access-profile-web1] quit
第六步:MAC接入模板、免认证规则与认证模板(官方命令照抄)
MAC接入模板(MAC优先就体现在这台设备同时建了MAC接入模板和Portal接入模板):
[DeviceA] mac-access-profile name m1
[DeviceA-mac-access-profile-m1] quit
免认证规则:认证没过之前,终端至少要能访问DNS,不然认证页面都打不开。示例放行的DNS服务器是10.23.202.1:
[DeviceA] free-rule-template name default_free_rule
[DeviceA-free-rule-default_free_rule] free-rule 1 destination ip 10.23.202.1 mask 32
[DeviceA-free-rule-default_free_rule] quit
认证模板把Portal接入模板、免认证规则模板、MAC接入模板、认证域全部挂到一起:
[DeviceA] authentication-profile name p1
[DeviceA-authentication-profile-p1] portal-access-profile web1
[DeviceA-authentication-profile-p1] free-rule-template default_free_rule
[DeviceA-authentication-profile-p1] mac-access-profile m1
[DeviceA-authentication-profile-p1] access-domain test
[DeviceA-authentication-profile-p1] quit
第七步:WLAN业务参数(官方命令照抄)
安全模板(open,准入控制交给Portal层)、SSID模板、VAP模板:
[DeviceA] wlan
[DeviceA-wlan] security-profile name wlan-security
[DeviceA-wlan-sec-prof-wlan-security] security open
[DeviceA-wlan-sec-prof-wlan-security] quit
[DeviceA-wlan] ssid-profile name wlan-ssid
[DeviceA-wlan-ssid-prof-wlan-ssid] ssid wlan-net
[DeviceA-wlan-ssid-prof-wlan-ssid] quit
[DeviceA-wlan] vap-profile name wlan-vap
[DeviceA-wlan-vap-prof-wlan-vap] service-vlan vlan-id 101
[DeviceA-wlan-vap-prof-wlan-vap] security-profile wlan-security
[DeviceA-wlan-vap-prof-wlan-vap] ssid-profile wlan-ssid
[DeviceA-wlan-vap-prof-wlan-vap] authentication-profile p1
[DeviceA-wlan-vap-prof-wlan-vap] quit
[DeviceA-wlan] ap-group name ap-group1
[DeviceA-wlan-ap-group-ap-group1] vap-profile wlan-vap wlan 1 radio 0
[DeviceA-wlan-ap-group-ap-group1] vap-profile wlan-vap wlan 1 radio 1
[DeviceA-wlan-ap-group-ap-group1] quit
验证:走开再回来不用重输(官方检查结果原文)
- 完成配置后,用户可通过无线终端搜索到SSID为 wlan-net 的无线网络,使用手机关联"wlan-net"SSID,输入账号和密码。
- 认证成功后自动获得10.23.101.0/24网段IP地址,能够访问Internet资源。
- 管理员在DeviceA通过 display access-user 和 display access-user user-id user-id 查看在线用户详细信息。
- 手机去关联SSID,过一会再关联,无需再输入账号和密码,直接关联成功,能够访问Internet资源。
判读要点:最后一条就是本套配置的"效果验收"——手机断开重连不再弹页面、直接能上网,说明MAC优先的免重复认证已经生效;如果重连又要输密码,优先核对认证模板里 mac-access-profile 是否挂上、RADIUS侧的免认证时长参数是否下发。
配完后设备上的配置文件(官方原文,供逐行核对)
DeviceA关键段落:
#
sysname DeviceA
#
vlan batch 100 to 101 200
#
authentication-profile name p1
mac-access-profile m1
free-rule-template default_free_rule
portal-access-profile web1
access-domain test
#
dhcp enable
#
radius-server template radius_test
radius-server shared-key cipher %+%##!!!!!!!!!"!!!!"!!!!*!!!!Cd/`W03KjAwAqn64E<\TxGC_SOri<2BP\A+!!!!!2jp5!!!!!!B!!!!Oe2HMc->XMa#TLDZUaJBFJtm#XVj*E:S*|(N7`J1B:3QY!!!!!!!!!!!!!!!%+%#
radius-server authentication 10.23.200.1 1812 weight 80
radius-server accounting 10.23.200.1 1813 weight 80
#
free-rule-template name default_free_rule
free-rule 1 destination ip 10.23.202.1 mask 255.255.255.255
#
web-auth-server abc
server-source ip-address 10.23.200.3
server-ip 10.23.200.1
port 50200
url http://10.23.200.1:8080/portal
shared-key cipher %^%#-;k-</gjVJ=ZK&Ea)<WB(j1FD8HJOGq^@$Ly=\0Y%^%#
#
portal-access-profile name web1
web-auth-server abc
#
aaa
authentication-scheme radius_test
authentication-mode radius
accounting-scheme scheme1
accounting-mode radius
accounting realtime 15
domain test
authentication-scheme radius_test
accounting-scheme scheme1
radius-server radius_test
#
interface Vlanif100
ip address 10.23.100.1 255.255.255.0
dhcp select interface
#
interface Vlanif101
ip address 10.23.101.1 255.255.255.0
dhcp select interface
#
interface Vlanif200
ip address 10.23.200.3 255.255.255.0
#
interface 10GE 0/0/1
port link-type trunk
port trunk allow-pass vlan 100
#
interface 10GE 0/0/2
port link-type trunk
port trunk allow-pass vlan 200
#
capwap source interface vlanif 100
#
wlan
security-profile name wlan-security
security open
ssid-profile name wlan-ssid
ssid wlan-net
vap-profile name wlan-vap
service-vlan vlan-id 101
ssid-profile wlan-ssid
security-profile wlan-security
authentication-profile p1
regulatory-domain-profile name domain1
ap-group name ap-group1
regulatory-domain-profile domain1
radio 0
vap-profile wlan-vap wlan 1
radio 1
vap-profile wlan-vap wlan 1
#
mac-access-profile name m1
#
return
DeviceB配置文件:
#
sysname DeviceB
#
vlan batch 100
#
interface 10GE 0/0/1
port link-type trunk
port trunk pvid vlan 100
port trunk allow-pass vlan 100
#
interface 10GE 0/0/2
port link-type trunk
port trunk pvid vlan 100
port trunk allow-pass vlan 100
#
interface 10GE 0/0/3
port link-type trunk
port trunk allow-pass vlan 100
#
return
注意配置文件里两处密钥都显示为密文串,这是 cipher 加密的正常呈现,核对时别拿明文去对。
注意事项(官方口径整理)
- RADIUS服务器地址、端口号、共享密钥必须配置正确,并且和RADIUS服务器保持一致。
- Portal服务器模板里的 url 与 server-ip 指向同一台服务器,部署时换成实际Portal服务器地址;server-source 必须是设备上真实存在的接口IP(本例VLANIF200)。
- 免认证规则里放行DNS是硬需求:终端解析不了域名,认证页面就弹不出来;除了DNS,按需放行必要的资源即可,不要放开面。
- capwap dtls no-auth enable 只为AP首次上线取安全凭证,AP正常上线后应及时 undo 关闭,避免未授权设备接入网络。
员工和访客混用一张WiFi、免认证时长给多长才合适,这类策略的边界拿捏,诚鑫致达科技在贵州企业的无线项目里趟过不少坑。各厂商设备的命令与默认参数存在差异,本文步骤与命令均出自华为官方文档,操作前请核对你的设备型号与软件版本。
源:华为官方文档 AR路由器5700-6700-8000/dc_cfg_nac_wireless_portal_ar.md《举例:配置无线MAC优先Portal认证(使用Portal协议)》