V2ray Mikrotik Page
V2ray Mikrotik Page
/container set 0 host-time=yes
You must have physical access to the router to toggle the mode-button or perform a cold boot to enable the container package for security reasons.
For older MIPSBE or SMIPS devices, you cannot run containers. Instead, you set up V2Ray on a Raspberry Pi or a Linux VPS. The MikroTik then uses Policy Based Routing (PBR) or Mangle rules to redirect specific traffic to that V2Ray gateway. 2. Key Steps for Container Deployment (RouterOS v7)
This is the cleanest method. We will pull a lightweight V2Ray Docker image (e.g., v2fly/v2fly-core ) into RouterOS.
Enable MikroTik's built-in Web Proxy and tell it to use V2Ray as its parent proxy: v2ray mikrotik
The container package must be installed and enabled on your MikroTik device.
"inbounds": [ "port": 10808, "protocol": "socks", "settings": "auth": "noauth", "udp": true , "sniffing": "enabled": true, "destOverride": ["http", "tls"] , "port": 12345, "protocol": "dokodemo-door", "settings": "network": "tcp,udp", "followRedirect": true ], "outbounds": [ "protocol": "vmess", "settings": "vnext": [ "address": "your.server.ip.or.domain", "port": 443, "users": [ "id": "YOUR-V2RAY-UUID-HERE", "alterId": 0, "security": "auto" ] ] , "streamSettings": "network": "ws", "security": "tls", "wsSettings": "path": "/yourpath" ] Use code with caution.
A fully operational remote V2Ray server (VMess, VLess, or Trojan protocol) with its connection details (IP, port, UUID, and security settings).
To route your network traffic through a V2Ray proxy using a MikroTik router, the most efficient method is to /container set 0 host-time=yes You must have physical
Use MikroTik’s powerful firewall to ensure only Netflix or specific work tools go through the proxy, while local traffic stays on the high-speed ISP line.
What (VMess, VLESS, Trojan, etc.) does your server use? Share public link
MikroTik devices without hardware-accelerated encryption will experience performance bottlenecks when running heavy TLS-based configurations (like VLESS-XTLS). If your speeds drop, upgrade your hardware or shift encryption duties to an external x86 micro-appliance. Conclusion
Add a route pointing all traffic in that table to the container IP: The MikroTik then uses Policy Based Routing (PBR)
Enable the built-in MikroTik Web Proxy and point its parent proxy to the V2Ray container:
In RouterOS v7, you must explicitly declare routing tables before adding routes.
Create a list of IP ranges or domains (using RouterOS v7’s dynamic DNS lists) that need to bypass local restrictions.
# Mark specific connections that need proxying /ip/firewall/mangle/add chain=prerouting src-address=192.168.88.0/24 dst-address-list=!local_subnets action=mark-routing new-routing-mark=to-v2ray passthrough=yes # Create a route that forces marked traffic to pass through the container's proxy IP /routing/table/add name=to-v2ray fib /ip/route/add dst-address=0.0.0.0/0 gateway=172.16.10.2@main routing-table=to-v2ray Use code with caution.
A common pitfall with network-wide proxies is , where your ISP blocks or spies on your DNS requests before the V2Ray tunnel can route the actual data.
Create a virtual ethernet interface for the container: interface veth add name=veth-v2ray address=172.16.10.2/24 gateway=172.16.10.1