Disclaimer. The rules and numbers in this post are simplified for illustration and based on published research. Take them as a starting point, not a copy-paste.
I use Tor and Mullvad, and I also run things in the cloud that I’d rather not have attacked through them. So I got curious: if someone came at one of my endpoints through a proper anonymity stack, what would I see, and could I do anything about it? Short answer: “not much” and “sort of”.
Tor, Mullvad and the hosting company Njalla are great at protecting people’s privacy, and people should be free to use them. But whatever protects an ordinary user protects an attacker just as well, and nobody needs them to reach the systems I run. So this post is about blocking them there. At least, that’s the attempt.
Blocking works great on people who can’t be bothered. Not so much on people who are paid to bother, or who really, really want to. But even for them, it closes the easy, well-known paths and forces them to improvise. I’ve always been a big believer in that. People make mistakes when they improvise, I get to make moves too, and the whole thing becomes a game of chess.
The setup
The attacker’s, not mine:
- A laptop running Tails or Qubes-Whonix, which send everything through Tor.
- A MiFi (a pocket 4G router) with a prepaid SIM.
- A Mullvad VPN tunnel, paid in cash or Monero.
- Tor, running inside that tunnel.
- A server rented from Njalla and administered over Tor.
Every hop only knows its neighbours. My service, at the very end, sees the Njalla server and nothing else. And unlike a Tor exit, a rented Njalla server is on no Tor list anywhere.
So just block the IPs, right?
A Tor exit isn’t the attacker’s machine. It’s shared by everyone using Tor at that moment, and the exit list has about 1,300 of them. Block a few and the next request comes out of another one. VPN exits are shared the same way. So what you actually want to block is the networks, which means first finding out where they are.
Finding the ranges
Tor was the easy one. Google keeps the Tor exit list as a named list,
iplist-tor-exit-nodes, and that’s what I use. Google doesn’t publish
what’s in it, so I can’t tell you how closely it tracks the Tor Project’s
list. Google also has iplist-vpn-providers and
iplist-anon-proxies,
for “low-reputation VPN providers” and “open anonymous proxies”. It
doesn’t say which providers those cover either, so I can’t tell you
whether Mullvad is in there. They’re worth running in preview next to your
own rules to see what they catch.
Mullvad was annoying. Its relay API gives you the address you connect to for each relay, but your traffic leaves from a different address, and the API doesn’t list those. tmctmt’s measurements suggested the exits sit in the same /24 as the connect address, so I took the /24 around every connect address and treated it as Mullvad.
Then I checked. I connected to 96 relays and asked am.i.mullvad.net which
address I came out of, and added ipapi.is’s exit
table. That covers a little over half
of Mullvad’s relays. For nearly all of them the guess holds. For 23 it
doesn’t: de-ber-wg-004, for example, takes connections on 193.32.248.69
and exits from 151.241.171.0/24, and nothing in the API tells you that.
So the list is the connect /24 of every active WireGuard relay, plus the exit /24s I measured that the API doesn’t give you: 240 /24s today. Any unmeasured relay that exits somewhere else gets through. For IPv6 I do the same with the /48 around each relay’s IPv6 connect address. I haven’t measured IPv6 exits at all, so that part is a guess. And because most relays are rented from hosting companies, a /24 also covers some of those companies’ other customers. Hold that thought.
Part of Mullvad is easier. Mullvad works with 31173 Services AB, which hosts some of Mullvad’s servers in its own network, AS39351. Matching on that AS number catches those relays, plus any ranges they add later.
Njalla publishes nothing, so I went digging in RIPE. Its named ranges
(NJALLA-VPS-NET, NJALLA-VPS2-NET, NJALLA-NET) are announced by
AS39287 (Materialism s.r.l.) and AS54990 (1337 Services LLC), so I match
on those two ASNs. To be honest, nothing from Njalla itself ties it to
them; the registry names are all I have. And those ASNs host more than
Njalla: they also announce ranges registered to other privacy hosts. I’m
fine blocking those too, but it’s a choice, not an accident.
| Network | What they publish | What I match on |
|---|---|---|
| Tor | the exit list | Google’s iplist-tor-exit-nodes |
| Mullvad | connect addresses only | the /24 (and IPv6 /48) around each active relay, measured exit /24s, plus AS39351 |
| Njalla | nothing | AS39287 and AS54990, which host Njalla among others |
Load balancers and VMs need separate rules
In most clouds, traffic reaches you in one of two ways, and each has its own place to block things. I’ll use Google Cloud here, but the split is the same elsewhere.
Through a load balancer, your backends only see the load balancer’s own addresses, so a firewall rule naming a Tor exit never matches. On Google Cloud you block here with a Cloud Armor security policy.
Straight to a VM with its own external address, the load balancer is never involved, so the security policy never sees it. On Google Cloud you block here with a firewall policy rule on the VPC.
Neither covers for the other. You need both. And make sure there’s no
third way in: a Cloud Run service, for example, also has its own run.app
URL that skips the load balancer, and Cloud Armor with it, unless you set
ingress = "INGRESS_TRAFFIC_INTERNAL_LOAD_BALANCER".
The Cloud Armor rules
Threat intelligence lists and address groups need Cloud Armor Enterprise:
resource "google_compute_project_cloud_armor_tier" "enterprise" {
cloud_armor_tier = "CA_ENTERPRISE_PAYGO"
}
The Mullvad ranges go in an address group, a named list of ranges a rule can refer to. I build it at plan time from the relay API plus my measured exits:
data "http" "mullvad" {
url = "https://api.mullvad.net/www/relays/all/"
}
locals {
# Bridges and inactive relays never send user traffic out, so skip them.
mullvad_relays = [
for r in jsondecode(data.http.mullvad.response_body) : r
if r.type == "wireguard" && r.active
]
# Exit /24s I measured in November 2026 that the relay API doesn't give you.
mullvad_exits = [
"31.169.53.0/24",
"45.130.200.0/24",
"85.203.54.0/24",
"91.190.106.0/24",
"146.70.124.0/24",
"151.241.171.0/24",
"155.2.219.0/24",
"158.173.46.0/24",
"169.150.201.0/24",
"185.209.198.0/24",
"194.36.27.0/24",
"194.127.165.0/24",
]
mullvad_ranges = sort(distinct(concat(
[
for r in local.mullvad_relays :
"${cidrhost("${r.ipv4_addr_in}/24", 0)}/24"
],
local.mullvad_exits,
)))
mullvad_ranges_v6 = sort(distinct([
for r in local.mullvad_relays :
"${cidrhost("${r.ipv6_addr_in}/48", 0)}/48"
if r.ipv6_addr_in != null && r.ipv6_addr_in != ""
]))
}
resource "google_network_security_address_group" "mullvad" {
provider = google-beta
name = "mullvad-relays"
parent = "projects/${var.project}"
location = "global"
type = "IPV4"
capacity = 1000
purpose = ["CLOUD_ARMOR"]
items = local.mullvad_ranges
lifecycle {
# Don't push a deny list built from a broken or empty API response.
precondition {
condition = length(local.mullvad_ranges) > 100 && length(local.mullvad_ranges) < 900
error_message = "Mullvad range count looks wrong, check the relay API."
}
}
depends_on = [google_compute_project_cloud_armor_tier.enterprise]
}
resource "google_network_security_address_group" "mullvad_v6" {
provider = google-beta
name = "mullvad-relays-v6"
parent = "projects/${var.project}"
location = "global"
type = "IPV6"
capacity = 1000
purpose = ["CLOUD_ARMOR"]
items = local.mullvad_ranges_v6
depends_on = [google_compute_project_cloud_armor_tier.enterprise]
}
cidrhost turns each connect address into its /24 (or /48), and
distinct drops the duplicates. An address group holds either IPv4 or
IPv6, so there are two. You can’t change capacity after creation, so
leave room. The precondition stops a bad API response from turning into a
deny list, which matters once you run this on a schedule.
Then the policy, one rule per network:
resource "google_compute_security_policy" "lb" {
name = "lb"
rule {
action = "deny(403)"
priority = 1000
preview = true
description = "tor exits"
match {
expr {
expression = "evaluateThreatIntelligence('iplist-tor-exit-nodes')"
}
}
}
rule {
action = "deny(403)"
priority = 1100
preview = true
description = "njalla, and mullvad relays hosted in as39351"
match {
expr {
expression = "origin.asn == 39287 || origin.asn == 54990 || origin.asn == 39351"
}
}
}
rule {
action = "deny(403)"
priority = 1200
preview = true
description = "mullvad relay /24s"
match {
expr {
expression = "evaluateAddressGroup('${google_network_security_address_group.mullvad.name}', origin.ip) || evaluateAddressGroup('${google_network_security_address_group.mullvad_v6.name}', origin.ip)"
}
}
}
rule {
action = "allow"
priority = 2147483647
description = "default"
match {
versioned_expr = "SRC_IPS_V1"
config {
src_ip_ranges = ["*"]
}
}
}
depends_on = [google_compute_project_cloud_armor_tier.enterprise]
}
The same thing again, for the VMs
Same three networks as firewall policy rules, assuming
google_compute_network_firewall_policy.vpc already exists. Firewall rules
can’t match on an ASN, so I fetch the prefixes the three ASNs announce from
RIPEstat
at plan time, the same way as the Mullvad list:
data "http" "asn" {
for_each = toset(["39287", "54990", "39351"])
url = "https://stat.ripe.net/data/announced-prefixes/data.json?resource=AS${each.key}"
}
locals {
asn_prefixes = flatten([
for d in data.http.asn :
[for p in jsondecode(d.response_body).data.prefixes : p.prefix]
])
vpc_ranges_v4 = sort(distinct(concat(
local.mullvad_ranges,
[for p in local.asn_prefixes : p if !strcontains(p, ":")],
)))
vpc_ranges_v6 = sort(distinct(concat(
local.mullvad_ranges_v6,
[for p in local.asn_prefixes : p if strcontains(p, ":")],
)))
}
resource "google_network_security_address_group" "vpc" {
name = "mullvad-njalla"
parent = "projects/${var.project}"
location = "global"
type = "IPV4"
capacity = 1000
items = local.vpc_ranges_v4
}
resource "google_network_security_address_group" "vpc_v6" {
name = "mullvad-njalla-v6"
parent = "projects/${var.project}"
location = "global"
type = "IPV6"
capacity = 1000
items = local.vpc_ranges_v6
}
resource "google_compute_network_firewall_policy_rule" "tor" {
firewall_policy = google_compute_network_firewall_policy.vpc.name
rule_name = "deny-tor-exits"
priority = 1000
direction = "INGRESS"
action = "deny"
enable_logging = true
match {
src_threat_intelligences = ["iplist-tor-exit-nodes"]
layer4_configs {
ip_protocol = "all"
}
}
}
resource "google_compute_network_firewall_policy_rule" "mullvad_njalla" {
firewall_policy = google_compute_network_firewall_policy.vpc.name
rule_name = "deny-mullvad-njalla"
priority = 1100
direction = "INGRESS"
action = "deny"
enable_logging = true
match {
src_address_groups = [google_network_security_address_group.vpc.id]
layer4_configs {
ip_protocol = "all"
}
}
}
resource "google_compute_network_firewall_policy_rule" "mullvad_njalla_v6" {
firewall_policy = google_compute_network_firewall_policy.vpc.name
rule_name = "deny-mullvad-njalla-v6"
priority = 1101
direction = "INGRESS"
action = "deny"
enable_logging = true
match {
src_address_groups = [google_network_security_address_group.vpc_v6.id]
layer4_configs {
ip_protocol = "all"
}
}
}
Threat intelligence here is a Cloud NGFW Standard feature, billed separately from Cloud Armor. And a group that isn’t for Cloud Armor holds at most 1,000 entries, which is why these are separate groups.
Now the part that’s easy to get wrong. By default, Google Cloud checks
your classic VPC firewall rules
first,
and if one of them allows the traffic, it stops there. So an old
default-allow-ssh from 0.0.0.0/0 lets Tor in, no matter what the
policy says. Either move those allow rules into the policy, or tell the
network to check the policy first:
resource "google_compute_network" "vpc" {
# ...
network_firewall_policy_enforcement_order = "BEFORE_CLASSIC_FIREWALL"
}
Inside the policy, the deny rules need a higher priority than the rules that allow traffic to your VM, like SSH to a bastion. In a firewall policy, priority 0 is the highest, and if a packet matches more than one rule, only the highest-priority one is enforced. The deny rules above are 1000 to 1101, so any allow rule for the VM needs a number above 1101. An SSH allow rule at 500 would win, and Tor would get in.
Start in preview mode
Remember those /24s that cover other people’s servers? This is why every
Cloud Armor rule starts with preview = true: it logs what it would have
denied without denying it. Turn on request
logging for the
backend service and look for matches:
resource.type="http_load_balancer"
jsonPayload.previewSecurityPolicy.name="lb"
jsonPayload.previewSecurityPolicy.priority=(1000 OR 1100 OR 1200)
If a week of matches is nothing but scanners, flip preview to false. If
a real customer shows up, take that range out first.
Firewall policy rules have no preview mode, so add those after the preview week, with the ranges that survived.
Alert when it fires
I want to know when one of these rules actually catches something, so I set up two log-based alerts that email me: one for the load balancer and one for the VMs.
resource "google_monitoring_notification_channel" "email" {
display_name = "Security alerts"
type = "email"
labels = {
email_address = "you@example.com"
}
}
resource "google_monitoring_alert_policy" "lb" {
display_name = "Blocked on load balancer"
combiner = "OR"
notification_channels = [google_monitoring_notification_channel.email.id]
conditions {
display_name = "Cloud Armor match"
condition_matched_log {
filter = <<-EOT
resource.type="http_load_balancer"
(jsonPayload.previewSecurityPolicy.name="lb" OR
(jsonPayload.enforcedSecurityPolicy.name="lb" AND
jsonPayload.enforcedSecurityPolicy.outcome="DENY"))
EOT
}
}
alert_strategy {
notification_rate_limit {
period = "300s"
}
}
}
resource "google_monitoring_alert_policy" "vpc" {
display_name = "Blocked on VM"
combiner = "OR"
notification_channels = [google_monitoring_notification_channel.email.id]
conditions {
display_name = "Firewall deny"
condition_matched_log {
filter = <<-EOT
resource.type="gce_subnetwork"
log_id("compute.googleapis.com/firewall")
jsonPayload.disposition="DENIED"
jsonPayload.rule_details.priority=(1000 OR 1100 OR 1101)
EOT
}
}
alert_strategy {
notification_rate_limit {
period = "300s"
}
}
}
The load balancer alert fires on preview matches as well as real denies, so it works during the preview week too.
Final thoughts
Blocking Tor, Mullvad and Njalla doesn’t reveal who anyone is. It closes the well-known, proven paths, so an attacker has to come up with something else, even one who’s paid to go after you. Some won’t bother and move on to an easier target. The rest have to improvise. Like every other layer of defence, it isn’t bulletproof, but it’s one more.
It also has clear limits. In the setup at the top, my service only ever sees the Njalla server, so of all these rules only the ASN one applies, and renting from any other privacy-friendly host gets around it. And paid attackers do use these routes: a ransomware group used Mullvad to reach its victims’ remote access, and in October someone took over AWS roles through Mullvad from two addresses this list blocks. But not everyone does. Groups like Volt Typhoon route through hacked home and office routers, and others run whole networks of them. Their traffic looks like ordinary users, and blocking the easy routes can push attackers towards exactly that. What I watch for once they’ve moved is a story for another time.
The Mullvad and ASN ranges are only as fresh as your last terraform apply, so run it on a schedule. The measured exit /24s don’t refresh at
all.
Disclaimer. The rules and numbers in this post are simplified for illustration and based on published research. Take them as a starting point, not a copy-paste.
If I got any of this wrong, tell me. I’d rather know.