WireGuard TCP drops: a new connection meets the bogons drop rule in the forward chain, ping does not
|

Troubleshooting: WireGuard TCP drops on a MikroTik router, and the bogons rule behind them

WireGuard TCP drops on a MikroTik router: ping works but new TCP and UDP connections vanish. The dead ends, the bogons rule behind them and the fix.

My WireGuard TCP drops on a MikroTik router took several troubleshooting sessions, and the cause was one firewall rule that I had not listed. The tunnel looked healthy and ping worked, but every new TCP connection from my LAN toward my server vanished without a trace. This article tells the story in the order I lived it, because the dead ends teach as much as the fix.

Quick answer — ping works through a WireGuard tunnel, but new TCP and UDP connections from the LAN vanish.

# List the real members of the address list that a drop rule uses
/ip/firewall/address-list/print where list=bogons
# The forward drop rule after the fix: it now applies to traffic from the WAN only
chain=forward action=drop dst-address-list=bogons in-interface-list=WAN

Details, explanations and checks follow below. Addresses are examples.

The symptom: WireGuard TCP drops with a healthy tunnel

The WireGuard tunnel joins my server and my MikroTik home router. Handshakes renew about every 25 seconds, ICMP passes, and connections started from the server toward LAN hosts work. However, any new TCP connection started by a LAN host toward the server’s tunnel address silently vanishes. There is no SYN, no RST and no answer, so the client just times out.

I found the problem while setting up MariaDB replication from my server to a machine at home. I had tried the tunnel address first. Because it failed, I had to use the server’s public address instead, restricted by firewalld to my home IP, and that stayed my workaround for a while.

The addresses below are examples, not mine:

  • LAN: 192.168.88.0/24, with a host at 192.168.88.17.
  • Tunnel: 10.99.0.0/24. The router interface has 10.99.0.2/24 and the server has 10.99.0.3.
  • The peer on the router uses allowed-address 10.99.0.3/32.
WireGuard TCP drops: a new connection meets the bogons drop rule in the forward chain, ping does not
Why ping passed and new connections did not: the path through the forward chain.

First checks: everything pointed at WireGuard

  1. I pinged the server from the LAN host. It worked.
  2. I ran nc -zv from the LAN host toward the server, on the MariaDB port and on an arbitrary port. Both timed out, so the problem was not specific to MariaDB.
  3. I ran tcpdump -i wg0 on the server during the test. Zero packets arrived, so the failure sat on the router or in the tunnel.
  4. A read-only API account showed nothing in the firewall filter, raw and mangle tables, because no rule counter moved during the test.
  5. With a full account, I added temporary accept rules at the top of the raw prerouting, filter forward and mangle postrouting chains, matching the exact test traffic. All three matched and passed the packets.
  6. A live /tool/sniffer capture on the WireGuard interface, run during the same test, captured zero packets.

At that point I concluded that the packet never left through the WireGuard interface. I blamed the RouterOS WireGuard send path. That conclusion was wrong, but it sent me down a long road.

The detours

Here are the detours that did not explain the WireGuard TCP drops, in the order I tried them.

  • The /24 against /32 theory. Forum threads describe the same symptom, with a peer allowed-address set to a whole /24 instead of the peer’s /32. My peer was already a /32, but the interface address was a /24. I changed the interface address to /32. The result was a total routing failure: ICMP died too, and the remote path I would have used to revert died with it. I reverted through the router’s local web interface. Nothing lasting broke, but the theory was disproven.
  • Fasttrack. I disabled it live, reproduced the bug, then enabled it again. It was not the cause.
  • MSS clamping and mangle rules. The mangle table only held dynamic fasttrack counters, so nothing there touched the SYN packets.
  • A suspicious counter. A high tx-error counter on the interface did not increase when I reproduced the bug, so it was stale.
  • UDP too. A traceroute from the LAN host got an answer from the router, then nothing beyond it, while ping to the same address worked. So the bug was not specific to TCP.
  • Winbox torch. On site, torch showed what the sniffer had shown: ICMP appeared, new flows did not.
  • A RouterOS upgrade. I read the changelog of the next release (my router ran 7.23.3) and found no matching fix, so I decided not to upgrade a production router for nothing.

The root cause of the WireGuard TCP drops: a static entry in the bogons list

The router had this rule in the forward chain: chain=forward action=drop dst-address-list=bogons. The bogons address list held a static entry for 10.0.0.0/8. My server’s tunnel address lies inside that range, so every new connection toward it matched the drop, whatever its source.

Ping worked because an ICMP accept rule sat earlier in the same chain. It let ICMP through before the traffic reached the bogons rule. The router’s own SSH to the server also worked, because the router generates that traffic itself. The MikroTik packet flow documentation says such traffic uses the output chain, while routed traffic uses the forward chain, so it never met the rule.

The proof was quick. I placed a temporary accept rule for dst-address=10.99.0.0/24 in the forward chain, ahead of the drop, and SSH from the LAN host passed immediately.

The fix

I added in-interface-list=WAN to the existing rule, so that bogon filtering only applies to traffic that comes from the WAN. Private ranges are legitimate on internal-facing chains, meaning the LAN and the VPN tunnels, so they must not be filtered there.

# The forward drop rule after the fix (properties of the existing rule)
chain=forward action=drop dst-address-list=bogons in-interface-list=WAN

Check that it worked

Repeat the test that failed. The connection now succeeds at once.

# The same test that timed out before the fix, from a host on the LAN
nc -zv 10.99.0.3 22

Why my debug rules hid the cause

Two mistakes kept me away from the answer for several sessions.

  • The accept rules that I placed at the top of each chain pre-empted every rule below them. They proved that my debug rule worked, not that no other rule would have dropped the packets. The moment I removed them, the original bogons drop resumed silently.
  • My early check of the bogons list looked for traffic being added to the list. It did not look at the entries already sitting in the list as static members.

If you see the same symptom

  • Dump the real members of every address list that a drop rule uses: /ip/firewall/address-list/print where list=.
  • Remember that a debug accept rule at the top of a chain hides every rule below it.
  • If ping works but new TCP and UDP flows fail, look for an ICMP accept rule that sits before a drop rule.
  • Compare the chains: traffic that the router generates uses output, and routed traffic uses forward.

What I take away

  • The WireGuard TCP drops came from a firewall rule, not from WireGuard.
  • Eliminating other layers is useful, but only if each test really covers the rule you suspect.
  • Scope bogon filtering to the WAN, because private ranges belong on internal chains.

Sources

Related articles

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *