In June I turned on UniFi's Country Restriction and blocked eleven countries at the WAN. Both directions. Nothing inbound from them, nothing outbound to them. It took five minutes in the UI. Verifying it took longer, because the method I use for every other rule on this gateway doesn't work for this one.
What It Is#
UniFi Network → Security → Threat Management → Country Restriction. You pick countries, an action, and a direction. I chose block, both directions, applied to the WAN interface.
GeoIP blocking is not a security boundary on its own. Attackers rent infrastructure anywhere. What it does is cut the background noise: automated scanning and commodity botnets that originate from regions I have no reason to talk to. Fewer junk connections reach the firewall rules that actually matter.
The List#
Two groups. Nation-state origins, and regions with high volumes of commodity cybercrime aimed at home networks.
| Code | Country | Why |
|---|---|---|
| CN | China | APT1, APT40, APT41 |
| RU | Russia | APT28, APT29, Sandworm |
| KP | North Korea | Lazarus Group |
| IR | Iran | APT33, APT34, APT35 |
| AF | Afghanistan | No legitimate inbound expected |
| BY | Belarus | State-aligned operations |
| NG | Nigeria | BEC, credential phishing |
| RO | Romania | RDP brute force, card skimming |
| VN | Vietnam | APT32 (OceanLotus) |
| BR | Brazil | Banking trojans |
| UA | Ukraine | Ransomware-as-a-service |
This is a list for my network, not a judgment about the people in those countries. If you have family, customers, or a VPN exit in one of them, your list will look different. Outbound blocking will break things you use. Check before you copy it.
Why Outbound Too#
Inbound blocking stops scans. Outbound blocking is the part that matters if something inside is already compromised. Malware calling home to infrastructure in a blocked region gets nowhere. It's a cheap second layer behind the zone firewall and DNS filtering.
The Verification Problem#
Everywhere else on this network I verify at the kernel. Make a change in the UI, SSH in, read iptables, count the rules. The UI can lie. The kernel can't.
GeoIP is the exception. On the UCG Fiber, Country Restriction isn't implemented as iptables rules or an nftables set. A proprietary daemon handles it. iptables shows nothing. nft list ruleset shows nothing. If you go looking for the block in the usual places, you'll conclude it isn't there.
It is. You just have to look somewhere else.
Verify the Config the Controller Pushed#
The gateway keeps the configuration the controller pushed as JSON under /data/udapi-config/. The newest udapi-net-cfg-*.json file has a services.geoipFiltering section. That's the source of truth for this feature.
What I check:
enabledistrueactionisblockdirectionisboth- the interface list contains the WAN interface
- the country list matches what the UI shows
If those match the UI, the block is configured where the daemon reads it. That's one step removed from the kernel, and I'm honest about that. It's the deepest layer this feature exposes.
The Principle#
Verify at the lowest layer the feature actually lives in. For zone rules that's iptables. For GeoIP on this gateway, it's the pushed config. The method changes. The rule doesn't: the UI is a claim, not a proof.