Mikrotik - V2ray

# Add a routing mark for proxied traffic
/ip firewall mangle
add chain=prerouting src-address=192.168.88.0/24 dst-address=!192.168.88.10 \
    protocol=tcp action=mark-routing new-routing-mark=v2ray-mark

Set up a V2Ray client (such as v2ray-core, xray, or sing-box) on a separate device (e.g., a Raspberry Pi, a spare PC, or a VM).

On your local V2Ray server (e.g., IP 192.168.88.254):

On MikroTik:

/ip socks set enabled=yes version=5 server=192.168.88.254:1080
/ip firewall nat add chain=srcnat action=masquerade
/ip route add gateway=192.168.88.254

To force all HTTP/HTTPS through the proxy: v2ray mikrotik

/ip firewall mangle add chain=prerouting protocol=tcp dst-port=80,443 action=mark-routing new-routing-mark=via-socks
/ip route add gateway=192.168.88.254 routing-mark=via-socks

Warning: The native MikroTik Socks client is not as performant as a modern proxy. It lacks UDP support and can struggle with high concurrency. Use this only for low-bandwidth browsing.


/ip socks
set enabled=yes port=1080

/ip firewall nat add chain=dstnat protocol=tcp dst-port=80,443 action=redirect to-ports=1080

But this only forwards to MikroTik’s SOCKS, not to V2Ray. Better to use Method 1 with a proxy box.


/ip firewall mangle add chain=prerouting connection-mark=v2ray-conn action=mark-routing new-routing-mark=to-v2ray

To avoid routing everything (like Netflix or local banking), use MikroTik's DNS to identify blocked domains. # Add a routing mark for proxied traffic

/ip firewall mangle add chain=prerouting dst-address=192.168.88.11 action=mark-routing new-routing-mark=to-v2ray

This way, only when a user requests twitter.com (resolved to your fake IP) does the traffic hit V2Ray.


Route specific IPs or countries through the V2Ray container's gateway.

First, give the container a static IP and enable IP forwarding inside the container. Then, on MikroTik: To force all HTTP/HTTPS through the proxy: /ip

This way, only traffic destined to blocked IPs goes through V2Ray.


/container config set registry-url=https://registry-1.docker.io tmpdir=containers/storage
/container mounts add name=v2ray-conf src=/v2ray/conf dst=/etc/v2ray