Routing specific IP only via the VPN (routing-mark doesn't work)

Hi,
I have my MT configured as Wireguard client which works fine. Now I’d like to route specific device (FireTV Stick) in my home network to use this VPN connection. I found this how-to:
https://superuser.com/a/999549
but the problem is that routing-mark is broken or no longer supported in ROS 7.1.3:

[admin@MikroTik] > /ip route add dst-address=0.0.0.0/0 distance=1 gateway=192.168.102.1 routing-mark=vpn
expected end of command (line 1 column 70)

Other tutorials in the internet are based on the same routing-mark method, any idea how can I do this now?

You need to define routing table first (in /routing/table) and route’s parameter is now named routing-table. And instead of using mangle rule, you can use routing rule:

/routing rule
add src-address=x.x.x.x/32 action=lookup-only-in-table table=vpn

ok, so that doesn’t work:

> /routing/table/add name=pve-vpn
> /ip route add dst-address=0.0.0.0/0 distance=1 gateway=192.168.102.1 routing-table=pve-vpn
> /ip firewall nat add chain=srcnat out-interface=wireguard-client-pve action=masquerade
> /routing/rule/add src-address=192.168.1.105/32 action=lookup-only-in-table table=pve-vpn
input does not match any value of table

> /routing/table/print 
Flags: D - dynamic; X - disabled, I - invalid; U - used 
 0 D   name="main" fib 

 1     name="pve-vpn"

EDIT:
Adding route table with FIB enabled made it available in the last command however the IP (192.168.1.105) lost access to the internet so it doesn’t work in this way.

There’s nothing clearly wrong here. You added new routing table with default gateway and told router that 192.168.1.105 should use it. So if 192.168.102.1 is reachable (you have some address/mask on WG interface where the subnet contains 192.168.102.1), if it’s not blocked by local or remote firewall, tunnel works, etc… it should work.

VPN is up and running, from MT:

[admin@MikroTik] > ping 192.168.102.1
  SEQ HOST                                     SIZE TTL TIME       STATUS                                                                                                                                                                                                     
    0 192.168.102.1                              56  64 85ms198us 
    1 192.168.102.1                              56  64 37ms710us 
    2 192.168.102.1                              56  64 37ms67us  
    3 192.168.102.1                              56  64 37ms442us 
    sent=4 received=4 packet-loss=0% min-rtt=37ms67us avg-rtt=49ms354us max-rtt=85ms198us

From my desktop (not 192.168.1.105):

❯ mtr 192.168.102.1 --report
Start: 2022-03-12T20:07:45+0000
HOST: k-desktop                   Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 192.168.1.1                0.0%    10    0.4   0.4   0.3   0.5   0.0
  2.|-- 192.168.102.1              0.0%    10   37.3  37.0  36.7  37.3   0.2

or to my mobile connected to the same VPN:

❯ mtr 192.168.102.3 --report
Start: 2022-03-12T20:15:29+0000
HOST: k-desktop                   Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- 192.168.1.1                0.0%    10    0.3   0.4   0.3   0.5   0.1
  2.|-- 192.168.102.1              0.0%    10   37.4  37.3  37.0  37.8   0.3
  3.|-- 192.168.102.3              0.0%    10  107.5 113.5  76.1 165.6  30.5

And ping from 192.168.1.105 to 192.168.102.1? Or anything else from 192.168.1.105, do you see it on wireguard-client-pve interface using Tools->Torch?

I can’t ping anything except 192.168.1.x hosts from .105

❯ ping 192.168.102.1   
PING 192.168.102.1 (192.168.102.1) 56(84) bytes of data.
From 192.168.1.1 icmp_seq=3 Destination Net Unreachable

❯ ping 1.1.1.1      
PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.
From 192.168.1.1 icmp_seq=1 Destination Net Unreachable
From 192.168.1.1 icmp_seq=2 Destination Net Unreachable

so it looks like routing is missing somewhere.

also there is nothing in Torch for this interface.

removed

Config attached. I am pretty sure I’ve done everything that is mentioned in the above link for my particular needs.
config.rsc (4.71 KB)

I see route, but not in pve-vpn table.

ok, so I am lost now. How can I display then add it? What I am looking at here:

[admin@MikroTik] > ip/route/print where routing-table 
Flags: D - DYNAMIC; A - ACTIVE; c, s, v, y - COPY
Columns: DST-ADDRESS, GATEWAY, DISTANCE
#     DST-ADDRESS        GATEWAY               DISTANCE
  DAv 0.0.0.0/0          pppoe-out1                   0
  DAc 38.242.191.252/32  pppoe-out1                   0
  DAc 192.168.1.0/24     bridge1                      0
  DAc 192.168.102.0/24   wireguard-client-pve         0
0  As 0.0.0.0/0          192.168.102.1                1

[admin@MikroTik] > routing/route/print 
Flags: A - ACTIVE; c, s, v, y - COPY; H - HW-OFFLOADED
Columns: DST-ADDRESS, GATEWAY, AFI, DISTANCE, SCOPE, TARGET-SCOPE, IMMEDIATE-GW
    DST-ADDRESS           GATEWAY               AFI   DISTANCE  SCOPE  TARGET-SCOPE  IMMEDIATE-GW        
Av  0.0.0.0/0             pppoe-out1            ip4          0     30            10  pppoe-out1          
Ac  38.242.191.252/32     pppoe-out1            ip4          0     10                pppoe-out1          
Ac  192.168.1.0/24        bridge1               ip4          0     10                bridge1             
Ac  192.168.102.0/24      wireguard-client-pve  ip4          0     10                wireguard-client-pve
As  0.0.0.0/0             192.168.102.1         ip4          1     30            10  wireguard-client-pve
Ac  fe80::%ether1/64      ether1                ip6          0     10                ether1              
Ac  fe80::%bridge1/64     bridge1               ip6          0     10                bridge1             
A H ether1                                      link         0                                           
A H ether2-master                               link         0                                           
A H ether3                                      link         0                                           
A H pppoe-out1                                  link         0                                           
A H bridge1                                     link         0                                           
A H wireguard-client-pve                        link         0

is there equivalent of Linux “ip r s” command in MikroTik?

“/ip/route/print detail” shows more info, including routing table. But since in /routing/route/print it points to wireguard-client-pve, it looks like you have the right one. But then you posted older config (routing rule is missing there too).

removed

I removed that rule:

/routing/rule/add src-address=192.168.1.105/32 action=lookup-only-in-table table=pve-vpn

because if it is in place then that IP can’t access anything except 192.168.102.0/24 (VPN) and 192.168.1.0/24 (local) networks.

It is Wireguard installed on Debian. There are two clients configured on it. My MT router at home and my mobile phone for test purposes. With my mobile connected to it I can access anything I want routed via the VPN. From MT (client) I can ping Wireguard server IP (192.168.102.1), I don’t know though how can I run traceroute from MT using other than default gw. for example 192.168.102.1
EDIT:

[admin@MikroTik] > tool/traceroute interface=wireguard-client-pve 1.1.1.1
Columns: ADDRESS, LOSS, SENT, LAST, AVG, BEST, WORST, STD-DEV, STATUS
#  ADDRESS        LOSS  SENT  LAST   AVG  BEST  WORST  STD-DEV  STATUS                             
1  192.168.102.2  0%       3  0.4ms  0.4  0.3   0.5    0.1      host unreachable from 192.168.102.2
2                 0%       0  0ms               

[admin@MikroTik] > tool/traceroute interface=wireguard-client-pve 192.168.102.1
Columns: ADDRESS, LOSS, SENT, LAST, AVG, BEST, WORST, STD-DEV
#  ADDRESS        LOSS  SENT  LAST    AVG   BEST  WORST  STD-DEV
1  192.168.102.1  0%       6  36.4ms  44.7  36.4  84.2   17.7

102.1 is remote server, 102.2 is MT client IP.

removed

Not sure if I understand, but it is installed on bare metal Dell server in Poland in my dad’s company if that make sense.


B. YOu have two wireguard clients that connect to the Debian Device, a MT device at home, and a smart phone (mobile)

correct


The smart phone connects to the debian only for internet and anything else?

internet only, I don’t need to access remote LAN network.


The smart phone connects to the debian and then enters another tunnel and connects to the MT for internet? or anything else?

No, it just connects to Wireguard on Debian and then access the internet routed through it. This is for test purposes to verify if VPN itself works as expected.


the MT (user(s) connects to the debian for internet ?

No, MT has just a tunnel to Debian, the purpose is to configure single client/IP in MT local network to go through that tunnel. Rest clients should access Internet as normal via the MT pppoe.


The MT (user(s) connects to the debian for accessing a subnet or server?

Internet only routed via Debian for single IP behind the MT. Don’t need to access remote (Debian) LAN.