Page 1 of 1

Route site or ip out of the VPN

Posted: Mon Oct 11, 2021 7:23 pm
by jaxed8
Hello everyone
I want to route some websites or at least their IPs out of my VPN, with my current configuration I believe all of the traffics would go trough VPN and I want to keep it this way except for few websites.
This is my configuration:
config export.txt

Re: Route site or ip out of the VPN

Posted: Mon Oct 11, 2021 7:26 pm
by ingdaka
Add a new rule at mangle with action accept and set destination IP and put those rules at top of others!
Those are mine:
/ip firewall mangle
add action=accept chain=prerouting dst-address=192.168.1.0/24 src-address=192.168.1.0/24
add action=accept chain=prerouting dst-address=public-ip-of-website
add action=mark-routing chain=prerouting new-routing-mark=to-vpn passthrough=yes src-address=192.168.1.0/24

Re: Route site or ip out of the VPN

Posted: Mon Oct 11, 2021 8:19 pm
by jaxed8
Add a new rule at mangle with action accept and set destination IP and put those rules at top of others!
Those are mine:
/ip firewall mangle
add action=accept chain=prerouting dst-address=192.168.1.0/24 src-address=192.168.1.0/24
add action=accept chain=prerouting dst-address=public-ip-of-website
add action=mark-routing chain=prerouting new-routing-mark=to-vpn passthrough=yes src-address=192.168.1.0/24
Thanks but it didn't worked, and just made that ip inaccessible.

Re: Route site or ip out of the VPN  [SOLVED]

Posted: Mon Oct 11, 2021 9:43 pm
by sindy
Thanks but it didn't worked, and just made that ip inaccessible.
It's because Ilir probably hasn't noticed that you've got no srcnat rule except the one for out-interface=L2TP_XXXX.

So you can e.g. copy that rule and change out-interface=L2TP_XXXX to out-interface=ether10 in the copy. Or instead you can just remove the matching on out-interface, as the rule only acts on packets sent from 192.168.1.0/24 anyway.

Re: Route site or ip out of the VPN

Posted: Tue Oct 12, 2021 2:54 pm
by jaxed8
It's because Ilir probably hasn't noticed that you've got no srcnat rule except the one for out-interface=L2TP_XXXX.

So you can e.g. copy that rule and change out-interface=L2TP_XXXX to out-interface=ether10 in the copy. Or instead you can just remove the matching on out-interface, as the rule only acts on packets sent from 192.168.1.0/24 anyway.
Thanks man it worked.
So with this only that website gonna access my actual ip not any other website? I mean it's not leaking my ip in this way?

Re: Route site or ip out of the VPN

Posted: Wed Oct 13, 2021 6:41 pm
by jaxed8
up up

Re: Route site or ip out of the VPN

Posted: Wed Oct 13, 2021 8:01 pm
by sindy
So with this only that website gonna access my actual ip not any other website? I mean it's not leaking my ip in this way?
That's a complex topic.

First, you can choose whether to establish a connection via VPN or directly depending on the destination IP address, but multiple sites apparently unrelated to each other may run on the same IP address, and vice versa, the same site may be hosted at multiple IP addresses. You don't expect a high profile site like www.google.com to be served from a single server to all the clients in the world, do you? And vice versa, e.g. www.google.com and www.youtube.com are often served from the same IP to the same client.

Second, your IP address may leak via DNS unless you make sure that DNS queries are also sent via VPN. And e.g. Windows 10 used to send the DNS queries through all interfaces through which any route existed, ignoring the actual routing table.

Re: Route site or ip out of the VPN

Posted: Fri Oct 15, 2021 9:39 pm
by jaxed8
So with this only that website gonna access my actual ip not any other website? I mean it's not leaking my ip in this way?
That's a complex topic.

First, you can choose whether to establish a connection via VPN or directly depending on the destination IP address, but multiple sites apparently unrelated to each other may run on the same IP address, and vice versa, the same site may be hosted at multiple IP addresses. You don't expect a high profile site like www.google.com to be served from a single server to all the clients in the world, do you? And vice versa, e.g. www.google.com and www.youtube.com are often served from the same IP to the same client.

Second, your IP address may leak via DNS unless you make sure that DNS queries are also sent via VPN. And e.g. Windows 10 used to send the DNS queries through all interfaces through which any route existed, ignoring the actual routing table.
Thanks man, but how to route the DNS via VPN?
My DNS settings:
Screenshot 2021-10-15 220811.jpg