This project provides the build and configuration information to run Tailscale in Mikrotik Container. Container is MikroTik's own implementation of Docker(TM), allowing users to run containerized environments within RouterOS.
This project is recommended for research and testing purposes only. Running Container currently requires installing the development branch of RouterOS and is unsupported for production use. Testing indicates there are also significant performance impacts: running a unidirectional IPerf UDP test of 50 Mbps via the container on a Mikrotik hAP ac3 consumes ~75% of the router's CPU.
The instructions below assume a use case for tailscale-enabled hosts accessing a router connected LAN subnet. The container runs as a tailscale subnet router on a Mikrotik hAP ac3. There are two subnets configured:
- 192.168.88.0/24: the default bridge with physical LAN interface ports, routed to the tailscale network
- 172.17.0.0/16: the docker bridge with a virtual ethernet (veth) interface port for the container
A WAN interface is configured as per default configuration on ether1 for connectivity to the Tailscale Network. Note storage of the docker image on the router uses a USB drive mounted as disk1 due to the limited storage (128MB) available on the router.
The build script uses Docker Buildx.
- In
build.sh
set the PLATFORM shell script variable as required for the target router CPU - see https://mikrotik.com/products/matrix - In
Dockerfile
set the following argument.
Argument | Description |
---|---|
TAILSCALE_PASSWORD | Password for root user |
- Run
./build.sh
to build the image. The build process will generate a container image filetailscale.tar
The router must be be running RouterOS v7.5beta4 or later with the container package loaded; this section follows the Mikrotik Container documentation with additional steps to route the LAN subnet via the tailscale container.
-
Upload the
tailscale.tar
file to your router. Below we will assume the image is located atdisk1/tailscale.tar
-
Enable container mode, and reboot.
/system/device-mode/update container=yes
- Create a veth interface for the container.
/interface/veth add name=veth1 address=172.17.0.2/16 gateway=172.17.0.1
- Create a bridge for the container and add veth1 as a port.
/interface/bridge add name=dockers
/ip/address add address=172.17.0.1/16 interface=dockers
/interface/bridge/port add bridge=dockers interface=veth1
- Enable routing from the LAN to the Tailscale Network
/ip/route/add dst-address=100.64.0.0/10 gateway=172.17.0.2
- Create environment variables as per the list below.
Variable | Description | Comment |
---|---|---|
AUTH_KEY | Tailscale reusable key | Generate the key from the tailscale console. |
ADVERTISE_ROUTES | Comma-separated list of routes to advertise | |
CONTAINER_GATEWAY | The Container bridge IP address on the router |
/container/envs
add name="tailscale" key="AUTH_KEY" value="tskey-xxxxxxxxxxxxxxxxxxxxxxxx"
add name="tailscale" key="ADVERTISE_ROUTES" value="192.168.88.0/24"
add name="tailscale" key="CONTAINER_GATEWAY" value="172.17.0.1"
- Create a container from the tailscale.tar image
/container add file=disk1/tailscale.tar interface=veth1 envlist=tailscale root-dir=disk1/containers/tailscale hostname=mikrotik dns=8.8.4.4,8.8.8.8
If you want to see the container output in the router log add logging=yes
- Optional - configure the container to startup on boot.
/system/script
add name="tailscale" source= {
:delay 60s
/container
start [find tag="tailscale:tailscale"]
}
/system/schedule
add name=tailscale on-event=tailscale start-time=startup interval=0
Ensure the container has been extracted and added by verifying status=stopped
using /container/print
/container/start 0
In the Tailscale console, verify the router is authenticated and enable the subnet routes. Your tailscale hosts should now be able to reach the router's LAN subnet.
The container exposes a SSH server for management purposes using root credentials, and can be accessed via the router's tailscale address or the veth interface address.
We welcome suggestions and feedback from people interested in integrating Tailscale on the RouterOS platform. Please send a PR or create an issue if you're having any problems.