Community discussions

MikroTik App
 
aciddo
just joined
Topic Author
Posts: 3
Joined: Thu Nov 22, 2018 2:16 pm

[MT] OpenVPN Server and static route gateway issue

Wed Mar 11, 2020 9:24 pm

Hello,

I have MT at home with OpenVPN server configured onto it. There's an OpenVPN client, on a different location, dialling in to the home OpenVPN server.

Home subnet is 192.168.1.0/24 (MT lan ip is 192.168.1.1)
OpenVPN server ip address is: 10.0.2.5
Remote subnet is: 192.168.144.0/24
Remote OpenVPN client ip address is: 10.0.5.10 (dynamically assigned once the openvpn link is established).

I want to configure a static route for accessing the remote subnet (192.168.144.0/24) from home subnet (192.168.1.0/24).

As I read in wiki, OpenVPN server implementation in MT does not support configuring static routes on the ovpn server itself ?
So, I tried setting a static route on MT ...
/ip route add dst-address=192.168.144.0/24 gateway=<ovpn-client> gateway-status=<ovpn-client> check-gateway=ping distance=1


I've configured the OpenVPN client with a static route for reaching home subnet (192.168.1.0/24).

Everything works as expected, the only problem is ... once the OpenVPN link drops, then the static route from MT side is going inactive (which is expected).
However, when ovpn link is back, the static route is still unable to reach the gateway=<ovpn-client>, even though the interface is up.
So, to overcome the problem I have to edit static route and manually select <ovpn-client> as the gateway, each time the ovpn tunnel drops and comes back.

Is there a better way to handle this ? possibly with a script ?

Thanks,
Yannis
 
tdw
Forum Guru
Forum Guru
Posts: 2086
Joined: Sat May 05, 2018 11:55 am

Re: [MT] OpenVPN Server and static route gateway issue  [SOLVED]

Wed Mar 11, 2020 10:16 pm

Create an OVPN server binding interface - this provides an unchanging name to which routes for firewall rules may be attached, you do not need to check the gateway status.

Alternatively you may be able to add routes to the PPP secret which are created and bound to the dynamic interface - I haven't tried this with OVPN connections, which do not quite fit into the standard PPP model, but this certainly works with SSTP and L2TP/IPsec.
 
aciddo
just joined
Topic Author
Posts: 3
Joined: Thu Nov 22, 2018 2:16 pm

Re: [MT] OpenVPN Server and static route gateway issue

Thu Mar 12, 2020 12:47 am

Creating an OVPN server binding interface did the trick. I had tried adding the routes on the ppp secrets section, but that seemed to be ignored by OVPN.

Many thanks,
Yannis