N
N
Nicholas Secret2016-09-30 22:28:19
VPN
Nicholas Secret, 2016-09-30 22:28:19

How to change routes depending on the destination address on Mikrotik?

There is a working tunnel with openVPN server. Mikrotik Opnvpn client. If I set the client's openvpn settings to ad default route, then all traffic goes through vpn and everything is fine. But that doesn't suit me.
I want traffic to go through the provider's gateway in all directions except for the ones I specify.
Tried to use this article. But firstly, nothing worked, and secondly, I don’t understand why I should add the entire subnet if I need only one ip address from it (or a group of ip addresses, depending on the situation, but in general it’s not an ip address, but a DNS name) .
Can you recommend articles or maybe implementation steps? Thanks
Given (addresses are fictitious)
White ip on the VPS server on the interest venet0: 1.1.1.1
OpenVPN on the VPS creates a network 192.168.200.0/24
as I understand it, the server ip becomes 192.168.200.1 by tun0
Mikrotik
Gray ip from the provider on ether1-gateway 10.1.66.171 Mikrotik
address in the local network 192.168.88.1
Accordingly, the DHCP server will unravel this and only this range.
When connecting to the openVPN server ip 192.168.200.6 I
propose to create a trial rule based on the site 2ip.ru 178.63.151.224
The current route table with a gateway from the provider
0c2fef0b09df40518ab08fc8824d0773.png
The route table in which all traffic goes through the openvpn gateway
8be9d55359704941b2bc6c5f11527918.png
It seems to me that I did not format the filter table correctly. I just made one article on the Internet, I don’t remember the address, here it is, maybe add something?
b60935466bd6435db4f891e081668f7f.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
Gregory, 2016-10-01
@Ncla

Another example that will come in handy for many: redirect all TCP connections to the OVPN gateway, and rkn.gov.ru to the default gateway.

/ip firewall address-list add list=RKN address=rkn.gov.ru
/ip firewall mangle add chain=prerouting protocol=tcp src-address=192.168.1.0/24 dst-address-list=RKN action=accept
/ip firewall mangle add chain=prerouting protocol=tcp src-address=192.168.1.0/24 dst-address=!192.168.0.0/16 action=mark-routing new-routing-mark=ovpn-route
/ip route add dst-address=0.0.0.0/0 gateway=ovpn-out1 distance=1 routing-mark=ovpn-route

source: https://habrahabr.ru/post/271707/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question