Named locations: getting IP ranges and countries right in Conditional Access
Named locations look simple, but trusted IPs and country blocks are easy to get subtly wrong. What they can and can't do, and how to use them well.
Named locations let Conditional Access policies react to where a sign-in comes from. There are two kinds.
IP ranges
A list of public IPv4 and IPv6 ranges, such as your office internet connections or VPN egress. You can mark a range as trusted, which lowers risk in Identity Protection and lets policies include or exclude "all trusted locations".
- Use your egress IP addresses: the ones the internet sees, not internal ranges.
- Remember IPv6. If your offices have it, sign-ins may come from IPv6 addresses you haven't listed.
- Keep the list current when ISPs or VPN providers change.
Countries and regions
Locations can be defined by country, determined either from the IP address or from GPS coordinates via Authenticator. GPS needs the user to share location from the app, so use it carefully.
Good patterns
- Block unexpected countries where you have no staff or business. Keep an exception process for travel.
- Don't skip MFA because a user is in the office. It's tempting, but an attacker inside your network, or a compromised device in the office, then gets an easier ride. Use location as a signal, not a pass.
- Protect security info registration. Requiring that MFA methods are registered from a trusted location, or with a temporary access pass, makes it harder for an attacker with a stolen password to add their own method.
Building a country block safely
- Export a month of sign-ins and list the countries successful sign-ins came from. You'll find more than you expect: travel, VPNs and cloud services.
- Create a named location of the countries you allow, then a policy that blocks everything except that location. An allow-list is easier to reason about than a long block-list.
- Exclude break-glass accounts, and decide how travellers request an exception (a temporary group exclusion works well).
- Run it in report-only for two weeks before switching it on.
SigninLogs
| where TimeGenerated > ago(30d) and ResultType == "0"
| summarize Users = dcount(UserPrincipalName), SignIns = count() by Country = tostring(LocationDetails.countryOrRegion)
| order by SignIns descWatch out for
- Mobile networks sometimes route traffic through another country.
- Cloud services signing in for users, such as some third-party integrations, appear from their own data centres.
- Unknown locations: an IP that can't be placed counts as an unknown country, which you can choose to include or exclude.
This post was last checked against Microsoft's documentation over six months ago. The approach should still hold, but check the linked sources for anything that has changed before you act on it.
Next in Conditional Access from zero · part 5 of 7Rolling out "require compliant device" without a flood of tickets →