📌 概述
本指南详细介绍如何在 Windows Server 环境下配置 DirectAccess + NPS + RADIUS + Microsoft Authenticator OTP 进行多因素认证(MFA)。相对于前文,本文力求简洁。
1️⃣ 服务器环境准备
✅ 服务器需求
组件 | 需求 |
---|---|
DirectAccess 服务器 | Windows Server 2016/2019/2022(加入 AD 域) |
NPS 服务器(RADIUS) | Windows Server 2016/2019/2022 |
Active Directory(AD) | 必须已部署,支持用户身份验证 |
证书服务(CA) | 可选(用于 OTP 认证) |
客户端设备 | Windows 10/11 企业版 + Microsoft Authenticator(iOS/Android) |
✅ 端口和网络要求
-
DirectAccess 服务器需要公网 IP 或 NAT 转发(TCP 443)
-
RADIUS 服务器需要 UDP 1812(认证)和 UDP 1813(计费,可选)
-
客户端必须能够访问 Microsoft Authenticator 进行 OTP 认证
2️⃣ 配置 NPS(RADIUS)服务器
1. 安装 NPS 角色
-
在 NPS 服务器上,打开 服务器管理器 → 添加角色和功能
-
选择 基于角色的安装,添加 网络策略和访问服务(NPS) 角色
-
安装完成后,打开 NPS 控制台(nps.msc)
-
右键 NPS(本地) → 选择 注册到 Active Directory,确保 NPS 服务器能够认证 AD 用户
2. 添加 DirectAccess 服务器为 RADIUS 客户端
-
在 NPS 控制台 → RADIUS 客户端 → 新建
-
名称:
DirectAccess Server
-
IP 地址:输入 DirectAccess 服务器的内网 IP
-
共享密钥:输入复杂密码(DirectAccess 服务器稍后会用到)
3. 创建 RADIUS 认证策略(OTP 认证)
-
在 NPS 控制台 → 策略 → 网络策略 → 新建
-
策略名称:
DirectAccess-OTP
-
条件:
-
添加 客户端 IPv4 地址,输入 DirectAccess 服务器的 IP
-
-
身份验证方式:
-
选择 EAP(扩展身份验证协议) → EAP-MSCHAPv2
-
启用 OTP 认证支持
-
-
点击“应用”并确定
3️⃣ 配置 DirectAccess 服务器
1. 启用 OTP 认证
-
在 DirectAccess 服务器,打开 PowerShell(管理员权限)
-
运行以下命令启用 OTP:
Enable-DAOTPAuthentication
-
配置 DirectAccess 使用 RADIUS 进行 OTP 认证:
Set-DAOtpAuthentication -RadiusServer "NPS_Server_IP" -SharedSecret "YourRadiusSecret"
-
确保 DirectAccess 服务器能解析 AD 和 NPS 服务器的 DNS 名称
2. 绑定 OTP 证书(可选)
如果使用 AD 证书服务(CA),请确保 DirectAccess 服务器能够颁发 OTP 认证证书。
4️⃣ 客户端配置和测试
1. 在 Windows 10/11 设备上启用 DirectAccess
-
运行
Get-DAConnectionStatus
检查 DirectAccess 状态 -
连接到互联网,等待 DirectAccess 自动建立 VPN 隧道
-
登录时,系统会提示输入 OTP
2. 配置 Microsoft Authenticator
-
在手机上下载 Microsoft Authenticator(iOS / Android)
-
添加新账户 → 选择 其他(自定义)
-
扫描 OTP 服务器提供的二维码
-
生成 6 位动态密码
-
在 Windows 认证界面输入 OTP,完成登录
📌 结论
✅ 采用 DirectAccess + Microsoft Authenticator OTP,提升远程访问安全性 ✅ 结合 RADIUS 认证,兼容 Windows AD 体系 ✅ 支持 软件 OTP(手机 APP 认证),避免硬件令牌成本 ✅ 客户端无需额外配置,可自动连接企业网络
📌 自动化部署脚本(PowerShell)
# 安装 NPS 角色
Install-WindowsFeature -Name NPAS -IncludeManagementTools
# 启用 DirectAccess OTP 认证
Enable-DAOTPAuthentication
Set-DAOtpAuthentication -RadiusServer "NPS_Server_IP" -SharedSecret "YourRadiusSecret"
# 配置 RADIUS 客户端
New-NpsRadiusClient -Address "DirectAccess_IP" -SharedSecret "YourRadiusSecret" -Name "DirectAccessServer"
# 配置 NPS 认证策略
New-NpsPolicy -Name "DirectAccess-OTP" -Condition "NAS IPv4 Address=DirectAccess_IP" -AuthenticationMethod MS-CHAPv2 -ProcessingOrder 1
# 确保 DirectAccess 服务器能解析 AD 和 NPS 服务器的 DNS 名称
Resolve-DnsName -Name "YourDomain.local"
✅ 以上 PowerShell 脚本可简化 NPS + DirectAccess OTP 认证的安装和配置。 ✅ 运行后,DirectAccess 服务器将自动启用 OTP,支持 Microsoft Authenticator 认证。 ✅ 可根据企业需求进一步优化策略。
如有进一步问题或需要定制优化,请联系 IT 管理员!