MikroTik kill switch and leak check
Make selected LAN traffic stop instead of falling back to your normal connection when the ForestVPN container is down, then prove it with a test.
What you get
Traffic you have chosen to send through the tunnel stops, rather than leaving over your normal connection, whenever the ForestVPN container cannot be reached or its tunnel is down. You also get a test that shows it.
Before you start
- Device: a MikroTik that runs the ForestVPN container from the install command, with its default private addresses.
- Firmware: RouterOS 7 (tested on 7.24.1). The syntax differs from RouterOS 6.
- Where: paste on the box that routes your LAN and runs the container.
- Time: ten minutes, plus the test.
- What can break: the selected traffic stops whenever the tunnel is down, which is the point. A router that has no tunnel yet, for example before it is linked, gives the selected LAN no internet; link it from a phone on mobile data.
Steps
-
Paste the routing script from the router's status page, in any mode, or paste
:global fvLAN "all"before the install command. Every mode includes the kill switch:- a routing table
via-fvpnwith a default route to the container and a blackhole behind it; - a routing rule
lookup-only-in-table, so a marked packet is never looked up in the main table; - a forward drop for new connections that come back out of the container's veth from anything but the container itself, which is what a container with a dead tunnel sends;
- a forward drop from the selected LAN traffic to your internet interface list.
The script and its modes are in choosing what goes through the tunnel, step 1.
- a routing table
-
Optional: for marks of your own, use the
rulesmode. It adds the table and the kill switch without marking anything. Mark traffic intovia-fvpnyourself, with comments that do not start withforestvpn: pasting the script again removes every object whose comment does. -
Check IPv6. The tunnel is IPv4 only. The
allmode refuses the LAN's IPv6; the other modes only report it, so check whether the router routes IPv6, because then the traffic you selected also reaches its destination over IPv6, around the tunnel.Shows whether the router advertises IPv6 and has a default route
/ipv6/nd/print where ra-lifetime!=none /ipv6/route/print where dst-address="::/0" and routing-table="main"
Check it worked
First run the leak test below, then confirm that the drop counters rose and that the table is in place.
Shows the kill switch rules with their counters, and the route table
/ip/firewall/filter/print stats where comment~"kill switch"
/ip/route/print where routing-table=via-fvpnThe leak test, when nobody needs the internet. From a device on your LAN, open a "what is my IP" page: it should show the exit's address. Stop the container, wait half a minute and reload the page.
Stops the container
/container/stop [find name="fvpn"]The page must fail to load. If it shows your own address, traffic is leaking: see the table below. Start the container again afterwards.
Starts the container
/container/start [find name="fvpn"]Undo it
Removes the routing script's rules, the kill switch included
/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.1Rules of your own with other comments stay.
If something is wrong
| Symptom | Cause | Fix |
|---|---|---|
| Your own address shows after the test | A wrong bridge name or an empty internet list, so the drops match nothing | Check fvBR and fvWAN at the top of the script and /interface/list/member/print where list=WAN, then paste the script again. |
| The script stops with "there is no veth-fvpn" | The container is not installed on this router, or this is the install's lan mode | Run the install on the router that routes your LAN, in its default private mode. |
| Nothing loads even with the container running | The container's tunnel is down, so the kill switch is doing its job | Check the status page and /log, then troubleshooting. |
| Some sites stall for a long time | IPv6 is advertised with no default route | Give IPv6 a default route, or stop advertising one with /ipv6/nd/set [find] ra-lifetime=none. |
Limits
- It covers the traffic you selected: the whole LAN in
allmode, the named devices or services in the others. - IPv4 only: the
allmode refuses the LAN's IPv6, and the other modes leave IPv6 to you. - A kill switch on a router stops traffic. It does not tell you why the container is down; see troubleshooting.