Office

Exchange 企业邮箱限制 IP 地址登录

Exchange 企业邮箱限制 IP 地址登录

通过设置可以限制 Office 365 用户只能通过指定 IP 地址访问 Exchange 邮箱服务。

该方法适用于由世纪互联运营的 Office 365 服务。

解决方法

1、以管理员身份运行 Windows Powershell。

Exchange 企业邮箱限制 IP 地址登录

2、连接到 Exchange Online PowerShell,并验证管理员账号密码。

Set-ExecutionPolicy RemoteSigned
Install-Module ExchangeOnlineManagement
Connect-ExchangeOnline -ExchangeEnvironmentName O365China
Exchange 企业邮箱限制 IP 地址登录

3、创建最高优先级规则允许 PowerShell 连接,防止访问规则设置错误导致无法访问 PowerShell。

New-ClientAccessRule -Name "Always Allow Remote PowerShell" -Action Allow -AnyOfProtocols RemotePowerShell -Priority 1 

4、创建规则仅允许特定 IP 访问,将 192.168.1.1 替换为公司公网出口 IP,该方法默认对整个域生效。

New-ClientAccessRule -Name "Block External Access of All" -Action DenyAccess -AnyOfProtocols ExchangeActiveSync,ExchangeAdminCenter,ExchangeWebServices,IMAP4,OfflineAddressBook,OutlookAnywhere,OutlookWebApp,POP3,PowerShellWebServices,RemotePowerShell,REST,UniversalOutlook -ExceptAnyOfClientIPAddressesOrRanges 192.168.1.1 -Priority 2

5、如需对特定用户生效,可以通过添加 UsernameMatchesAnyOfPatterns 参数筛选特定用户。例如对账户名为 aaa@example.com 的邮箱进行限制。

New-ClientAccessRule -Name "Block External Access Test" -Action DenyAccess -AnyOfProtocols ExchangeActiveSync,ExchangeAdminCenter,ExchangeWebServices,IMAP4,OfflineAddressBook,OutlookAnywhere,OutlookWebApp,POP3,PowerShellWebServices,RemotePowerShell,REST,UniversalOutlook -ExceptAnyOfClientIPAddressesOrRanges 192.168.1.1 -UsernameMatchesAnyOfPatterns “*aaa*” -Priority 2

6、查看已创建的规则。

Get-ClientAccessRule
Exchange 企业邮箱限制 IP 地址登录

7、移除规则,将「Block External Access of All」替换为规则名称。

Remove-ClientAccessRule -Identity "Block External Access of All"

8、限制用户是通过 UsernameMatchesAnyOfPatterns 参数匹配用户名。

Get-ClientAccessRule | Select Name,UsernameMatchesAnyOfPatterns
Exchange 企业邮箱限制 IP 地址登录

本文为原创文章,著作权归作者所有:来自「KOBIN 技术随笔」作者的原创作品,转载请标明出处。
Exchange 企业邮箱限制 IP 地址登录
https://blog.kobin.cn/blog/program/p0/596.html
(0)

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

CAPTCHAis initialing...