The UniFi web interface is the intended control plane for the UCG Fiber gateway. But the interface can lie. Configuration migration bugs, failed deployments, and UI refresh issues can leave rules that appear correct in the UI not actually enforced at the kernel.
The kernel is the ground truth. You must learn to read kernel firewall rules and verify that what you see in the UI actually exists in iptables.
Why You Need This#
A firewall rule that appears in the UI but doesn't exist in the kernel is a security failure. Traffic that should be blocked flows freely. Segmentation is defeated. A DEFAULT DROP policy becomes a suggestion instead of a guarantee.
The only way to find this is to SSH into the gateway and read the kernel state with iptables.
Chain Naming Pattern#
UniFi generates kernel iptables chains with a consistent naming pattern:
UBIOS_{SRC}_{DST}_USER
{SRC} and {DST} are replaced with zone type codes. Learn these codes:
- Internal (LAN) =
LAN - Untrusted (Skynet, guest-like security posture) =
CUSTOM2 - Trusted (VPN, remote management) =
CUSTOM1 - VPN (WireGuard, Admin VPN) =
VPN - External (WAN) =
WAN - Gateway =
GW - Hotspot =
HOTSPOT
Example Chain Names#
- Internal traffic to External:
UBIOS_LAN_WAN_USER - Trusted traffic to External:
UBIOS_CUSTOM1_WAN_USER - Untrusted traffic to LAN:
UBIOS_CUSTOM2_LAN_USER - VPN traffic to Internal:
UBIOS_VPN_LAN_USER - Trusted traffic to Internal:
UBIOS_CUSTOM1_LAN_USER
Reading a Chain#
SSH to the gateway via ssh root@<gateway-ip> -p <ssh-port>. On my gateway the port isn't 22 — and I'm not publishing the one it is. You'll be prompted for UNIFI_OS_PASSWORD, which is set during gateway setup and is separate from your UniFi app account password.
Once connected, list a chain:
iptables -L UBIOS_LAN_WAN_USER -n --line-numbers
-L lists the chain. -n skips DNS resolution on IPs (faster). --line-numbers shows rule position so you can cross-reference with the UI.
The output shows each rule with its criteria: source IP, destination IP, protocol, port, action (ACCEPT, DROP, REJECT). If you have 15 rules in the UI and iptables shows 12, three rules failed to push.
ipset Inspection: Three Levels Deep#
When a rule's source or destination is a UniFi IP group, the rule matches against a kernel ipset instead of a literal IP. An ipset is a kernel data structure that efficiently stores and matches sets of IPs.
UniFi ipsets are typically nested three levels deep:
- Level 1:
list:set(contains pointers to other ipsets) - Level 2:
list:set(contains pointers to other ipsets) - Level 3:
hash:net(contains actual CIDR blocks)
Inspect an ipset with ipset list <name>. If the top level lists members that themselves list members, recurse down until you find hash:net entries with actual IP ranges.
If a list:set returns NOT IN SET for an IP that is definitely in the child hash:net, the ipset is corrupted and needs to be recreated.
Rule Comment IDs#
Each iptables rule in a UniFi chain has a comment. The comment encodes the UniFi rule ID. To map a kernel rule back to the UniFi UI:
0xFF × 2³² + [decimal comment value]
This formula converts the comment to the UniFi rule ID you can search for in the UI. It's a debugging tool when you need to correlate a kernel rule to its source.
SSH Access and Port Configuration#
Gateway SSH runs on a non-standard port. This is by design — it reduces exposure to opportunistic SSH brute-force attacks.
Access requires being on the MGMT VLAN or authenticated to the Admin VPN. You cannot SSH from the Users VLAN or the internet — the firewall blocks it.
Verification Workflow After Firewall Changes#
After every firewall rule change, run this workflow:
- SSH into the gateway.
- List each affected zone chain (
UBIOS_*_USER). - Count the rules. Do they match what the UI shows?
- For IP group-based rules, use
ipset list <name>to recurse and verify the child sets contain the expected CIDRs. - Verify that no ipsets report NOT IN SET for IPs that should be included.
This takes 5 minutes. It catches configuration bugs before they cause outages. The UI is not authoritative. The kernel is.