Route trafic from one wAP to VPN

I have two mikrotik routers. One router - 2011 (main) has public static IP address and has L2TP over ipsec vpn server running on it. I can connect to it from laptops and mobiles. When i connected, my ip changes to routers ip.

The second router 4011 dont have public static ip. On this RB4011 router is running 3 wAPs. Two physical: 5ghz and 2.4ghz. And 3rd one is virtual which is on 2.4ghz interface. I have one bridge which is spreading internet to all three wifi’s, virtual has another subnet so its not accessible from physical wAPs.

I want to make VPN connection between two routers, and the tunnel should be spread to only 3rd wAP (virtual). The tunnel should be always connected. So any time when im connecting to wifi 3, i should be under that vpn and all trafic should go through 2011 router. So my IP address should also change to public static from 2011 router. How I can achieve that?
IMG_8906.JPG

  1. You should setup a VPN connection between RB2011 and RB4011
  2. You can use firewall to allow only your src IP address to reach the destination router
  3. You can use policy routing and use a specific routing table for your src IP address which in your case the VPN will be your default Gateway…

Thank you for your answer.
I want my two other wAP’s on rb4011 still use my local internet IP. So the trafic from them should not go to VPN. Only from the 3rd one. Is it possible only with one internet provider’s dynamic ip on 4011?

It is not the WAPs traffic that goes through the VPN, but instead your Computers traffic…
Even if someone else connects to the same WAP he/she will be routed from the local ISP and not through the VPN…

I understand, thank you, I’ve corrected the question. I will provide image that will help me to explain what i want to achive
IMG_89062.JPG

Did you setup the L2TP tunnel ?
After that you need to configure your policy routing rules, under IP route rules, when the src address is the computer’s IP address to use the Table " VPN " and then in the IP routes you need a a record with gateway the remote VPN router and routing mark the " VPN " ..

yes I have setup L2TP tunnel, it works fine. Now i need to route all trafic from LAN2 to that VPN. Not only from PC2, but from all LAN2.
p.s. LAN1 should still use old gateway and goes to internet from my German provider.

Ok but why dont you start the configuration and see how it goes ?
As said earlier the steps are routing rules then routes also masquerade the LT2P interface, forgot to mention that before…

all trafic from LAN2

Under ip route rules you can select the interface you want, i have not tested with interface name but only with IP, but i guess it will work too…

super, now i can access to remote subnet from wlan3. but i still cant access internet over that vpn. from mobile phone its working fine, and my ip changes to ip of rb2011.
where to look now?

p.s.
also I found strange behavior, when i connected to vpn rb2011, it assigns to rb4011 ip 172.31.86.7 and to rb2011 172.31.86.6 randomly. so all settings on my rb4011 i do for this ip. But can it be static on remote side?
i thought 172.31.86.6 would be my router’s ip address, but when i connected simultainiosly from second device i got two new addresses 172.31.86.8 to rb2011 and 172.31.86.9 and rb4011
is it normal? each tunnel should have pair of unique IP’s?

There must be something wrong in your configuration…
I cant help you if i dont see the ip routes, ip route rules and ip firewall nat…

how can i help, screenshots or teamviewer?

Export with hide sensitive the following:
ip routes, ip route rules and ip firewall nat…

nat.png
routes.png
rules.png
this is on rb4011 (local)
wlan3 192.168.10.0/24

  1. In the ip route rules remove the interface value on your last rule… Also you dont need both routing mark and Table values, just set Table to “VPN”…
  2. In the ip routes, in the second rule, you must set the routing mark to “VPN”

thank you! it works superb

You are welcome…

Hello, here are my config sections (192.168.243.0/24 have to go via pptp-freebox):

/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade"
ipsec-policy=out,none out-interface-list=WAN
add action=masquerade chain=srcnat comment="masq. vpn traffic" src-address=
192.168.89.0/24
add action=masquerade chain=srcnat comment="masq. free vpn traffic"
out-interface=pptp-freebox src-address=192.168.243.0/24

/ip route
add disabled=no distance=1 dst-address=192.168.27.0/24 gateway=pptp-freebox
pref-src="" routing-table=freetab scope=30 suppress-hw-offload=no
target-scope=10
add disabled=no dst-address=0.0.0.0/0 gateway=pptp-freebox routing-table=
freetab suppress-hw-offload=no

/routing rule
add action=lookup disabled=no src-address=192.168.243.0/24 table=freetab

the vpn is up. the wlan clients with 192.168.243.0/24 adresses can ping only the bridge "freebridge" address (192.168.243.1). For other addresses it gives "no network".

Do you have any whole example that i can use? Up to now i can find only some small pieces of info and contradicting approaches to such separate routing...