Skip to content

Nuface Blog

隨意隨手記 Casual Notes

Menu
  • Home
  • About
  • Services
  • Blog
  • Contact
  • Privacy Policy
  • Login
Menu

Double NAT Issue with OPNsense (Resolved by Direct PPPoE Connection)

Posted on 2025-11-122025-11-12 by Rico

🧭 1. Background

During internal testing, my setup was:

[Test Host] → OPNsense → UserGW → Internet
NodeIP / Role
Test Host192.168.100.250 (GW: 192.168.100.253)
OPNsense LAN192.168.100.253
OPNsense WAN172.16.100.253 (GW: 172.16.100.251)
UserGW LAN172.16.100.251
UserGW WANPPPoE (Internet)

The test host attempted to SSH to an external server.
The external server received connection attempts (logged in iptables),
but the SSH client always timed out.


🧩 2. Analysis

The SSH server log showed the connection coming from:

UserGW's PPPoE public IP

That means:

  • OPNsense performed NAT once (192.168.100.250 → 172.16.100.253)
  • UserGW performed NAT again (172.16.100.253 → Public IP)

So packets went out, but the return path failed due to state mismatch between two firewalls.


⚙️ 3. Troubleshooting Steps

1️⃣ Verified NAT

Outbound NAT on OPNsense:

Source: 192.168.100.0/24
Interface: WAN (172.16.100.253)
Translation: Interface address

Confirmed working.

2️⃣ Checked Firewall Rules

LAN allowed outbound traffic.
WAN was default-blocked inbound.
However, return traffic was being dropped because state tracking didn’t match.

3️⃣ Tried “Sloppy State”

Setting WAN rule to State Type: sloppy state
helped slightly but didn’t fully resolve the problem.

4️⃣ Packet Capture

Using:

tcpdump -ni wan host <ssh_server_ip> and port 22

→ Outbound SYN visible
→ No SYN/ACK returning
Confirmed return traffic was lost between UserGW and OPNsense.


🧠 4. Root Cause

This was caused by double stateful NAT.
Both firewalls maintained separate state tables,
and when UserGW modified the packet during NAT,
OPNsense’s state table no longer matched — TCP handshake failed.


✅ 5. Solution

Simplify the topology by letting OPNsense directly dial PPPoE.

[Test Host] → OPNsense (PPPoE) → Internet
NodeIP / Role
Test Host192.168.100.250 (GW: 192.168.100.253)
OPNsense LAN192.168.100.253
OPNsense WANPPPoE (Public IP assigned by ISP)

After applying this change:
✅ SSH, Ping, and Web access all worked instantly.
✅ No more timeout issues — single NAT path, clean state tracking.


🧩 6. Technical Summary

ItemDescription
Root CauseDouble NAT → state mismatch
SymptomOutbound packets logged, but SSH timed out
Temporary FixSloppy state / manual NAT adjustment
Final FixLet OPNsense handle PPPoE directly
ResultStable, fully functional Internet access

💡 7. Recommendations

  • Enable Insight (Netflow) for traffic visibility.
  • Use Unbound DNS Resolver for internal name resolution.
  • Keep WAN inbound traffic blocked by default.
  • For multi-WAN in the future, plan Policy-Based Routing instead of chained NAT.

Recent Posts

  • Postfix + Let’s Encrypt + BIND9 + DANE Fully Automated TLSA Update Guide
  • Postfix + Let’s Encrypt + BIND9 + DANE TLSA 指紋自動更新完整教學
  • Deploying DANE in Postfix
  • 如何在 Postfix 中部署 DANE
  • DANE: DNSSEC-Based TLS Protection

Recent Comments

  1. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on High Availability Architecture, Failover, GeoDNS, Monitoring, and Email Abuse Automation (SOAR)
  2. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on MariaDB + PostfixAdmin: The Core of Virtual Domain & Mailbox Management
  3. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Daily Operations, Monitoring, and Performance Tuning for an Enterprise Mail System
  4. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Final Chapter: Complete Troubleshooting Guide & Frequently Asked Questions (FAQ)
  5. Building a Complete Enterprise-Grade Mail System (Overview) - Nuface Blog on Network Architecture, DNS Configuration, TLS Design, and Postfix/Dovecot SNI Explained

Archives

  • December 2025
  • November 2025
  • October 2025

Categories

  • AI
  • Apache
  • Cybersecurity
  • Database
  • DNS
  • Docker
  • Fail2Ban
  • FileSystem
  • Firewall
  • Linux
  • LLM
  • Mail
  • N8N
  • OpenLdap
  • OPNsense
  • PHP
  • QoS
  • Samba
  • Switch
  • Virtualization
  • VPN
  • WordPress
© 2025 Nuface Blog | Powered by Superbs Personal Blog theme