OSPF and OpenVPN Cost

Hello,

I would like to configure OSPF on my ROS VPN Server using openvpn.

The VPN Server has 7 clients (running ROS and ospf too in area 0.0.0.0).

If some client connect to the vpn server, the ospf will automatically add the interface to interface table, so it looks like this:

Flags: X - disabled, I - inactive, D - dynamic, P - passive
 #    INTERFACE                                                                                COST PRIORITY NETWORK-TYPE   AUTHENTICATION AUTHENTICATION-KEY
 0  P ether1                                                                                     10        1 default        none
 1    vpn-interconnect                                                                           10        1 default        none
 2  P ether2                                                                                     10        1 default        none
 3    vpn-axfone                                                                                 50        1 default        none
 4 D  <ovpn-blava>                                                                               10        1 broadcast      none
 5 D  <ovpn-nitra>                                                                               10        1 broadcast      none
 6 D  <ovpn-bela>                                                                                10        1 broadcast      none
 7 D  <ovpn-zilina>                                                                              10        1 broadcast      none
 8 D  <ovpn-bbystrica1>                                                                          10        1 broadcast      none

The problems are the virtual interfaces etc…

I can configure the cost for them using:
add interface= cost=200


The problem is when the client restarts the connection, the interface then look like this:

#    INTERFACE                                                                                COST PRIORITY NETWORK-TYPE   AUTHENTICATION AUTHENTICATION-KEY
 0  P ether1                                                                                     10        1 default        none
 1    vpn-interconnect                                                                           10        1 default        none
 2  P ether2                                                                                     10        1 default        none
 3    vpn-axfone                                                                                 50        1 default        none
 4    *F00009                                                                                   200        1 default        none
 5 D  <ovpn-blava>                                                                               10        1 broadcast      none
 6 D  <ovpn-nitra>                                                                               10        1 broadcast      none
 7 D  <ovpn-zilina>                                                                              10        1 broadcast      none
 8 D  <ovpn-bela>                                                                                10        1 broadcast      none
 9 D  <ovpn-bbystrica1>                                                                          10        1 broadcast      none

The interface I’ve added now looks like *F00009 and new virtual interface is added with cost 10.

I would like to configure the different cost for all the ovpn clients, since there will be multiple connections from one client with different links.

Would be glad if anyone could solve my problem,
Thank you.

This might not be completely what you want, but you could set the default interface to the VPN cost, and then manually define the static interfaces. I think you want different cost for different VPNs, which would have to be script-based.

You could try to define a new instance and then redistribute them into the main instance and set the following command to the metric you want:

metric-other-ospf

http://wiki.mikrotik.com/wiki/Manual:Routing/OSPF

This may not be exactly what you’re looking for, but it might be an alternative to scripting.