Docs

Choosing what goes through the tunnel

Optional RouterOS recipes for a ForestVPN router — send one group of apps, send everything, and stop traffic leaking when the tunnel is down.

Updated October 21, 2026

On this page (6)

Everything on this page is optional. A ForestVPN router tunnels its own traffic the moment it connects, and none of this is needed for that. This is the other job: deciding which of your LAN's traffic leaves through the exit, and what happens when the exit can't be reached.

The division of labour never changes. RouterOS decides what goes to the tunnel, the container tunnels whatever it's handed, and your account decides where it comes out. So all of this is ordinary RouterOS configuration — mangle marks, a routing table, a firewall rule — and none of it touches the container.

Read this first

Three facts decide whether any of it works. Skipping them is a night you don't get back.

Paste these on the box that routes your LAN. RouterOS's prerouting chain only sees traffic the box itself routes. On an access point sitting downstream of your real gateway, every rule below is inert — measured on a cAP ax whose own default route is the router upstream of it: the container tunnelled perfectly and no LAN client's traffic ever went near it. The container can live on that access point; the rules go on the gateway.

The exit admits one source address per device — the overlay lease it issued. A packet arriving with any other inner source is dropped, not routed, however correct your rules are. Something has to rewrite your LAN onto that lease, and which thing depends on the container:

ContainerWhat you have to do about it
suquant/fvpn — the account-managed appNothing. From version 0.3.9 the container masquerades whatever you forward into it onto its own lease, and follows that lease when it moves. The install command turns this on. The routing script below adds the router's own srcnat to the container, which images before 0.3.20 also need.
suquant/fvpnq — the raw tunnel, from a .conf you wroteAdd a src-nat to the Address in your .conf, which is also what you put in the exit's AllowedIPs. You chose it, so it is stable and a rule can name it.

Running a container older than 0.3.9? Re-run the install command — the rules below will mark and route perfectly and the exit will drop every packet, which reads as the LAN losing the internet outright the moment you add the routing rule.

FastTrack routes by the main table and skips the firewall. MikroTik's factory firewall fasttracks established connections. A fasttracked connection never reaches mangle or the filter rules again and is routed by the main table, so a long flow meant for the tunnel can leave over your normal connection, past your marks and your kill switch. The routing script puts accept rules above the fasttrack-connection rule so flows to and from the container are never fasttracked.

And the IPv6 half, which these rules can't do for you

Everything here is IPv4. If your router has working IPv6, every destination you select below is also reachable over v6, around the tunnel, and nothing warns you. If instead the router advertises itself as an IPv6 router without having a v6 default route, LAN clients send v6 at it and get nothing back — not even an error, because RouterOS 7 has no unreachable route for v6, only a silent blackhole. Devices without Happy Eyeballs — TVs, watches, anything doing a bare connect on an AAAA record — then stall for a full connect timeout on every v6 destination, which reads as "the internet is broken sometimes" and blames the Wi-Fi. This one line reports which of the two you're in:

# Does this router tell LAN clients it is their IPv6 router?
/ipv6/nd/print where ra-lifetime!=none
 
# Does it have somewhere to send their v6 traffic?
/ipv6/route/print where dst-address="::/0" and routing-table="main"

Answers to the first and none to the second is the second case. Give IPv6 a real default route, or stop advertising one with /ipv6/nd/set [find] ra-lifetime=none.

The routing script's Everything mode does not leave this to you: because the tunnel is IPv4 only, it refuses the LAN's IPv6 with a reject, so devices fall back to IPv4 at once. The other modes only report, and print the answer to this same check when you paste them.

Step 1 — the routing script

One script sets up everything the recipes below need. On the router's status page (http://172.31.254.2/, from a device on the LAN) pick Named devices, Named services or Everything, copy the script and paste it into the router's terminal. Or skip the page and paste :global fvLAN "all" before the install command: the install then applies the same script itself. The devices mode uses the addresses in the list fvpn-clients, the services mode the destinations in fvpn-dst, and the rules mode adds only the plumbing, for marks of your own (step 2a).

Every mode adds:

  • a routing table via-fvpn whose default route is the container, with a blackhole behind it and a rule that never lets a marked packet fall back to the main table. This is the kill switch: with the container stopped, the selected traffic stops instead of leaving over your normal connection. The kill switch recipe on the English and Russian help pages has the leak test;
  • a firewall drop for traffic the container hands back when its own tunnel is down, and for selected traffic heading straight to the internet;
  • the router's own srcnat to the container, and an MSS clamp for the tunnel's 1416-byte MTU;
  • FastTrack exemptions for flows to and from the container;
  • private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) stay off the tunnel, so your LAN, the modem's page and the container's /30 keep working.

It assumes MikroTik's defaults: the LAN bridge is called bridge and the list holding your internet interface is WAN. If yours differ, change fvBR and fvWAN in its first lines. It refuses, and changes nothing, if veth-fvpn is missing, if the install is in lan mode, or if the bridge or the list is not there. Every object it adds has a comment starting forestvpn, so pasting it again replaces the earlier copy and changes nothing else.

Check /container/print detail first. remote-image has to say 0.3.9 or later, and the cmd has to contain --nat-lan. Both come from the current install command; a container installed before that has neither, and the symptom is the LAN losing the internet outright the moment you add the routing rule in step 2.

Step 2a — optional: calls and messengers only

Start by pasting the routing script in rules mode: http://172.31.254.2/script?mode=rules from a device on the LAN, or :global fvLAN "rules" before the install command. It sets up the table, the kill switch and the rest without marking anything; the rules below are your marks.

The setup that's been running on our own RB3011 for months. It splits the problem the way the traffic actually splits: signalling is a handful of vendor hostnames, media is a port range on relays nobody publishes.

# Signalling, by hostname. A hostname in a RouterOS address list is not a
# static entry -- the router resolves it and keeps the answers fresh, which
# is the only form that survives a CDN moving under you.
/ip/firewall/address-list
add list=fvpn-via address=g.whatsapp.net      comment="fvpn: signalling"
add list=fvpn-via address=media.whatsapp.net  comment="fvpn: signalling"
add list=fvpn-via address=mmg.whatsapp.net    comment="fvpn: signalling"
add list=fvpn-via address=static.whatsapp.net comment="fvpn: signalling"
add list=fvpn-via address=web.whatsapp.com    comment="fvpn: signalling"
add list=fvpn-via address=api.telegram.org    comment="fvpn: signalling"
add list=fvpn-via address=core.telegram.org   comment="fvpn: signalling"
add list=fvpn-via address=web.telegram.org    comment="fvpn: signalling"
add list=fvpn-via address=chat.signal.org     comment="fvpn: signalling"
add list=fvpn-via address=storage.signal.org  comment="fvpn: signalling"
 
/ip/firewall/mangle
add chain=prerouting action=mark-connection new-connection-mark=via-fvpn \
    dst-address-list=fvpn-via \
    comment="fvpn: signalling by resolved vendor hostname"
 
# Media, by port -- the half an address list can never cover, because a call
# lands on whichever TURN relay the vendor picked that minute.
add chain=prerouting action=mark-connection new-connection-mark=via-fvpn \
    protocol=udp dst-port=3478-3481 \
    comment="fvpn: STUN/TURN media - calls in every major app"
add chain=prerouting action=mark-connection new-connection-mark=via-fvpn \
    protocol=tcp dst-port=3478-3481,5349,5350 \
    comment="fvpn: STUN/TURN over TCP and TLS"
add chain=prerouting action=mark-connection new-connection-mark=via-fvpn \
    protocol=udp dst-port=5060,5061 comment="fvpn: SIP"
add chain=prerouting action=mark-connection new-connection-mark=via-fvpn \
    protocol=tcp dst-port=5060,5061 comment="fvpn: SIP over TCP/TLS"
add chain=prerouting action=mark-connection new-connection-mark=via-fvpn \
    protocol=tcp dst-port=5222,5223 comment="fvpn: XMPP signalling"
 
# One routing decision for the whole connection. Marking the connection
# first and the route second -- rather than marking the route directly -- is
# what keeps a call that started on the tunnel on the tunnel.
add chain=prerouting action=mark-routing new-routing-mark=via-fvpn \
    passthrough=no src-address=192.168.88.0/24 connection-mark=via-fvpn \
    comment="fvpn: route marked connections via the exit"

The hostnames are a starting point, not an authority. Vendors add and retire them without telling anyone. Check /ip/firewall/mangle/print stats for counters that stay at zero — that's a rule matching nothing, not a rule doing its job quietly.

Step 2b — optional: everything

Paste the routing script in all mode (the Everything button, or :global fvLAN "all" before the install command). There is nothing to add to it: it marks everything from the LAN bridge that is not addressed to this router or to a private range, leaves the container's own traffic alone, and drops whatever would still reach the internet directly.

Everything also moves the LAN's DHCP DNS to 1.1.1.1 and 8.8.8.8, so lookups go through the tunnel too, and names only your router answers (a printer, a NAS, router.lan) stop resolving. The script prints the old value, and devices pick up the new one when they renew their lease. It also refuses the LAN's IPv6.

Checking it worked

# A rule sitting at zero packets is a rule matching nothing.
/ip/firewall/mangle/print stats
/ip/route/print where routing-table=via-fvpn
# The fasttrack-exemption rule has to be above the fasttrack rule.
/ip/firewall/filter/print

From a LAN device, load any "what is my IP" page. It should show the exit's country for the traffic you selected and your own for everything else. If it shows your own for everything, the usual cause is the first fact on this page: the rules are on a box that doesn't route the LAN.

Undoing it

The routing script's objects all carry a comment starting forestvpn, so removing them is exact. The container's own objects (its veth, address and list entry) are in other menus and stay.

/ip/firewall/mangle/remove [find where comment~"^forestvpn"]
/ip/firewall/filter/remove [find where comment~"^forestvpn"]
/ip/firewall/nat/remove [find where comment~"^forestvpn"]
/ipv6/firewall/filter/remove [find where comment~"^forestvpn"]
/routing/rule/remove [find where comment~"^forestvpn"]
/ip/route/remove [find where routing-table="via-fvpn" and !dynamic]
/routing/table/remove [find where name="via-fvpn"]
/ip/firewall/address-list/remove [find where list="forestvpn-direct"]
# Everything mode also changed the LAN's DHCP DNS: set it back to the value the script printed
# (on a factory-default router, the router's own LAN address):
#   /ip/dhcp-server/network/set [find where address="192.168.88.0/24"] dns-server=192.168.88.1

Rules from step 2a, and from older versions of this page, carry fvpn: comments. Remove them too, and before pasting the script again:

/ip/firewall/mangle/remove [find comment~"^fvpn:"]
/ip/firewall/filter/remove [find comment~"^fvpn:"]
/ip/firewall/nat/remove [find comment~"^fvpn:"]
/ip/firewall/address-list/remove [find comment~"^fvpn:"]
/ip/route/remove [find comment~"^fvpn:"]
/ip/address/remove [find comment~"^fvpn:"]
/routing/table/remove [find name="via-fvpn"]

The container keeps running, keeps its account link, and goes back to tunnelling only its own traffic. If something else is wrong, see troubleshooting.

Back to Help

Back to top

Ask us anything