V2ray Mikrotik (PROVEN · 2025)
To use V2Ray on MikroTik routers, you must utilize the Container feature introduced in RouterOS v7, as there is currently no native support for the V2Ray protocol. This allows you to run a V2Ray or Xray client within a virtualized environment on the router to bypass deep packet inspection (DPI) or censorship. 1. Prerequisites
RouterOS v7.x: Ensure your firmware is updated to version 7 or later.
Hardware Support: Your router must have an ARM, ARM64, or x86 CPU. MIPSBE devices generally do not support containers.
Container Package: The container package must be installed and enabled on your device. 2. Implementation Methods
There are two primary ways to set this up, depending on your technical comfort level:
Docker Containers (Recommended): Use a pre-built image such as teddysun/v2ray. Users on the MikroTik Forum have documented success using these images to run Xray/V2Ray clients.
SOCKS5/HTTP Proxy Tunnels: You can set up the container to act as a local SOCKS5 proxy. You then use MikroTik's firewall rules to redirect specific traffic to this proxy. Detailed environment variable setups for this method can be found on this GitHub Gist for V2Ray on MikroTik. 3. Configuration Steps
Enable Container Mode: You must manually enable the container feature via the console (/system/device-mode/update container=yes) and follow the physical trigger (reset button) requirement for security.
Set Up VETH and Bridge: Create a virtual ethernet interface (VETH) and a bridge to allow the container to communicate with the router's internal network.
Environment Variables: Define your server's details (address, port, UUID, and protocol like VMess or VLESS) within the container's environment settings. Refer to the Project V Official documentation for specific command-line arguments and configuration structures.
Routing: Use /ip/firewall/mangle rules to "mark" traffic you want to send through the V2Ray tunnel and use a custom routing table to send that traffic to the container's IP. 4. Community Resources
Discussion & Troubleshooting: The MikroTik community forum provides active threads where users share their config.json templates and solve architecture-specific errors. v2ray mikrotik
Alternative Tools: For specific protocols like VLESS, some users recommend looking into NTC (No Thought is a Crime) for "universal" VPN containers designed specifically for MikroTik environments.
VLESS Guides: If you specifically need VLESS support, this Gist for VLESS on MikroTik covers common pitfalls like link formatting and server parameter changes.
Configuring V2Ray on MikroTik RouterOS: A Comprehensive Guide
In the current landscape of network security, bypassing restrictions and ensuring privacy have become paramount. While V2Ray is a powerful platform for building custom proxy servers, MikroTik RouterOS is arguably the most versatile networking operating system for managing traffic. Combining the two allows you to create a secure, high-performance edge router that handles obfuscation, bypassing restrictions, and routing at the network level, rather than on individual devices.
This guide explains why you should use V2Ray on MikroTik, the prerequisites, and a step-by-step approach to setting it up using modern Docker container features. Why Use V2Ray on MikroTik?
Running V2Ray directly on a MikroTik router (via Container) offers several advantages over running it on computers or phones:
Network-Wide Coverage: Once configured, every device connected to your network (smart TVs, IoT devices, guests) automatically uses the V2Ray proxy.
Performance: MikroTik devices, especially those with modern CPUs (ARM/ARM64), can handle complex encryption, reducing the strain on endpoints.
Advanced Routing: You can use MikroTik's robust firewall mangle rules to decide exactly which traffic goes through V2Ray and which goes through your ISP, based on IP address, domain, or port.
Bypassing Restrictions: V2Ray is highly effective at obfuscating traffic to bypass firewall restrictions. Prerequisites
MikroTik Router with ARM/ARM64 CPU: V2Ray runs in a Docker container, requiring hardware that supports the container package (e.g., hAP ax2/ax3, RB4011, RB5009). To use V2Ray on MikroTik routers, you must
RouterOS Version 7.4+: Ensure your router is updated to support containerization.
V2Ray Server Details: You need the IP, Port, UUID, AlterId, and Transport settings (VMess/VLESS) from your V2Ray service provider.
USB Drive or Internal Storage: For storing the container image. Step-by-Step Implementation
Because RouterOS is a networking OS, the setup involves creating a container for V2Ray and then routing traffic through it using traditional NAT and firewall rules. 1. Enable Container Functionality
First, ensure the container package is installed and enabled, and that you have enabled container support in settings.
/system/package/print # Ensure container is enabled. If not, install and reboot. /system/device-mode/update container=yes Use code with caution.
Note: A physical reboot is required to enable container mode. 2. Configure Virtual Ethernet (veth)
Create a bridge for the containers and a virtual ethernet interface to act as the "bridge" between MikroTik and the V2Ray container.
/interface/bridge/add name=docker-bridge /interface/veth/add name=veth1 address=172.17.0.2/24 gateway=172.17.0.1 /interface/bridge/port add bridge=docker-bridge interface=veth1 /ip/address/add address=172.17.0.1/24 interface=docker-bridge Use code with caution. 3. Setup NAT and Firewall (Routing)
To allow the container to access the internet to connect to your V2Ray server, you must set up Source NAT.
/ip/firewall/nat/add chain=srcnat action=masquerade src-address=172.17.0.0/24 Use code with caution. 4. Create and Configure the V2Ray Container Components
You will need a lightweight V2Ray image (like v2fly/v2fly-core). You must create a configuration file (config.json) and mount it to the container.
/container/mounts/add name=v2ray_conf src=/path/to/your/config.json dst=/etc/v2ray/config.json /container/add remote-image=v2fly/v2fly-core:latest interface=veth1 root-dir=disk1/v2ray mounts=v2ray_conf Use code with caution.
Crucial Step: You must prepare a valid config.json file for your V2Ray server and ensure it is placed on the router's storage. 5. Routing Client Traffic (Mangle & Routing Table)
To make your local network traffic go through the container, you need to use mangle to mark traffic and a specific routing table to direct it.
# 1. Add Routing Table /routing/table/add name=to-v2ray fib # 2. Mark Routing (e.g., from a specific IP) /ip/firewall/mangle/add chain=prerouting src-address=192.168.88.50 action=mark-routing new-routing-mark=to-v2ray # 3. Add Rule to route marked traffic to the container /ip/route/add dst-address=0.0.0.0/0 gateway=172.17.0.2 routing-table=to-v2ray Use code with caution. Important Considerations
DNS Leaks: Ensure that your local clients are not leaking DNS queries to your ISP. Configure your V2Ray config file to handle DNS, or use RouterOS to force DNS queries through the proxy.
Resource Usage: V2Ray can be resource-intensive. Monitor your CPU usage using /tool/profile.
Auto-Start: By default, containers will start when the router boots up.
By setting up V2Ray on MikroTik, you achieve a high level of security and flexibility that cannot be matched by simple endpoint applications. If you're setting this up, let me know: Which MikroTik model are you using (e.g., hAP ax3, RB5009)? Are you using VMess or VLESS?
I can provide the specific config.json template for your setup. V2ray Client on Mikrotik - GitHub Gist
Components
- VPS (Ubuntu 22.04) running V2Ray (v4.x or v5-compatible branch) listening on TCP/WS+TLS.
- Local Linux device (Raspberry Pi / x86 VM) running redsocks2 or tun2socks to translate redirected traffic to SOCKS5 for V2Ray client.
- MikroTik RouterOS v7+ handling policy-based routing and dst-nat to redirect LAN client traffic to the local proxy.
4. Security Features
- TLS 1.2/1.3 - Encrypted transport
- XTLS (Vision) - Flow control and obfuscation
- Reality - Fingerprint camouflage
- Certificate Pinning - MITM protection
7. MikroTik Integration Methods
Basic container setup:
/container
add remote-image=teddysun/v2ray:latest interface=veth1 root-dir=disk1/v2ray \
mounts=config:/etc/v2ray start-on-boot=yes
Then bind container’s proxy port to a local address and redirect traffic as in Method 1.
Note: Container support is limited and not available on all RouterBOARD models.
Method 1: MikroTik as Transparent Gateway (Recommended)
This uses a separate device (Raspberry Pi, x86, or container) as the V2Ray client. MikroTik redirects all traffic to it.

