How to configure OpenVPN server on Mikrotik ROS 7.x - complete guide

This guide configures an IPv4 OpenVPN server on MikroTik RouterOS 7.20+ using UDP, AES-256-GCM, a client certificate and a username/password. The profile can be imported into OpenVPN Connect on Windows, Android and iOS.

Architecture

Remote clients connect to the MikroTik public endpoint. The router assigns a VPN address and pushes routes to two internal networks. The initial configuration uses split tunneling: internal traffic crosses the VPN, while ordinary internet traffic uses the client's local connection.

  1. Public endpoint: vpn.example.net, represented here by 203.0.113.10.
  2. OpenVPN listener: UDP port 1194, IP/TUN mode.
  3. VPN subnet: 10.250.60.0/24; router tunnel address 10.250.60.1.
  4. Client pool: 10.250.60.10–10.250.60.49.
  5. Internal networks: 192.168.40.0/24 and 192.168.50.0/24.
  6. Certificates: CA valid for 3650 days; server and client certificates valid for 1827 days, at least five years.

All addresses, names and accounts below are examples. Replace 203.0.113.10 with your public IP; it is a documentation address. The VPN subnet must not overlap the internal networks or the remote client's local network.

The router already has a working WAN/default route, routes to both internal networks and an existing stateful firewall that accepts established/related connections. Its WAN interface list must contain the actual internet interface. If the router sits behind another gateway, forward UDP 1194 there to the MikroTik WAN address as well.

Commands that add objects are intended for a new configuration. Output blocks are illustrative and shortened; most successful add/set commands return no text.

Allow UDP 1194 in the Firewall

Allow incoming VPN connections in the input chain. This rule is inserted before existing drop rules and does not replace the rest of the firewall.

/ip firewall filter add chain=input action=accept connection-state=new protocol=udp dst-port=1194 in-interface-list=WAN place-before=0 comment="OVPN: UDP listener"
/ip firewall filter print where comment="OVPN: UDP listener"

Example output, shortened:

0 chain=input action=accept connection-state=new protocol=udp
in-interface-list=WAN dst-port=1194

Synchronize the Router Clock

Certificate issuance and validation depend on accurate time. Enable the MikroTik NTP client and confirm synchronization before generating certificates. UTC is used here to keep the displayed timestamps consistent.

/system clock set time-zone-autodetect=no time-zone-name=Etc/UTC
/system ntp client set enabled=yes mode=unicast servers=0.pool.ntp.org,1.pool.ntp.org
/system clock print
/system ntp client print

Example output, shortened:

time: 12:00:00
date: 2026-10-26
time-zone-name: Etc/UTC
gmt-offset: +00:00

enabled: yes
status: synchronized
synced-server: 0.pool.ntp.org

Create the CA and Server Certificate

Create a dedicated CA, sign it and mark it trusted. Keep its private key on the router.

/certificate add name=vpn-root-ca common-name=Example-VPN-Root key-size=4096 digest-algorithm=sha256 days-valid=3650 key-usage=key-cert-sign,crl-sign
/certificate sign vpn-root-ca name=vpn-root-ca
/certificate set [find where name="vpn-root-ca"] trusted=yes

Create the server certificate with TLS server usage. The client profile will verify its Common Name, vpn.example.net, even when connecting to the public IP.

/certificate add name=vpn-server common-name=vpn.example.net subject-alt-name=DNS:vpn.example.net key-size=2048 digest-algorithm=sha256 days-valid=1827 key-usage=digital-signature,key-encipherment,tls-server
/certificate sign vpn-server ca=vpn-root-ca name=vpn-server

Example output, shortened:

progress: done

Create the Address Pool and PPP Profile

The PPP profile assigns VPN addresses. Its interface list groups dynamically created VPN interfaces for firewall rules.

/interface list add name=OVPN
/ip pool add name=vpn-address-pool ranges=10.250.60.10-10.250.60.49
/ppp profile add name=vpn-users local-address=10.250.60.1 remote-address=vpn-address-pool interface-list=OVPN use-ipv6=no only-one=no change-tcp-mss=yes
/ip pool print detail where name="vpn-address-pool"
/ppp profile print detail where name="vpn-users"

Example output, shortened:

name="vpn-address-pool" ranges=10.250.60.10-10.250.60.49

name="vpn-users" local-address=10.250.60.1 remote-address=vpn-address-pool
interface-list=OVPN use-ipv6=no only-one=no change-tcp-mss=yes

only-one=no permits simultaneous sessions using the same account. Use individual accounts and certificates so access can be managed separately.

Create a User and Client Certificate

Create the first PPP account, restricted to OpenVPN, and a certificate with TLS client usage. Replace the password placeholder with a unique strong password.

/ppp secret add name=user01 password="REPLACE_WITH_VPN_PASSWORD" service=ovpn profile=vpn-users
/certificate add name=vpn-client-user01 common-name=user01 key-size=2048 digest-algorithm=sha256 days-valid=1827 key-usage=digital-signature,key-encipherment,tls-client
/certificate sign vpn-client-user01 ca=vpn-root-ca name=vpn-client-user01
/certificate print where name~"^vpn-"

Example output, shortened:

Flags: K - PRIVATE-KEY; A - AUTHORITY; I - ISSUED; T - TRUSTED
NAME COMMON-NAME
KA T vpn-root-ca Example-VPN-Root
K I vpn-server vpn.example.net
K I vpn-client-user01 user01

The server will require both valid PPP credentials and a client certificate from this CA. Naming the client CN after the username is an administrative convention; it does not bind that certificate exclusively to the matching PPP account.

Configure the OpenVPN Server and Split Routes

Create a named UDP listener with the server certificate and PPP profile. The explicit cipher must match the client configuration. PAP credentials travel inside the TLS tunnel.

/interface ovpn-server server add name=vpn-udp port=1194 protocol=udp mode=ip netmask=24 certificate=vpn-server default-profile=vpn-users require-client-certificate=yes tls-version=only-1.2 auth=sha256 cipher=aes256-gcm user-auth-method=pap max-mtu=1400 keepalive-timeout=30 reneg-sec=3600 redirect-gateway=disabled enable-tun-ipv6=no push-routes="192.168.40.0 255.255.255.0,192.168.50.0 255.255.255.0" disabled=no
/interface ovpn-server server print detail where name="vpn-udp"

Example output, shortened:

name="vpn-udp" port=1194 mode=ip protocol=udp netmask=24
max-mtu=1400 keepalive-timeout=30 default-profile=vpn-users
certificate=vpn-server require-client-certificate=yes
tls-version=only-1.2 auth=sha256 cipher=aes256-gcm
redirect-gateway=disabled
push-routes="192.168.40.0 255.255.255.0,192.168.50.0 255.255.255.0"
enable-tun-ipv6=no user-auth-method=pap

The network-and-netmask route format works across the target versions; some releases may display routes in CIDR form. redirect-gateway=disabled leaves the client's default internet route unchanged. Reconnect clients after changing pushed routes.

Allow VPN Access to the Internal Networks

Add the permitted destinations to an address list. Place VPN-specific forwarding rules before existing drop rules. The final scoped drop prevents VPN clients from reaching other routed destinations through this router.

/ip firewall address-list add list=VPN-LAN address=192.168.40.0/24
/ip firewall address-list add list=VPN-LAN address=192.168.50.0/24
/ip firewall filter add chain=forward action=drop in-interface-list=OVPN place-before=0 comment="OVPN: deny other forwarding"
/ip firewall filter add chain=forward action=accept in-interface-list=OVPN src-address=10.250.60.0/24 dst-address-list=VPN-LAN place-before=[find where comment="OVPN: deny other forwarding"] comment="OVPN: VPN to LAN"
/ip firewall filter add chain=forward action=accept connection-state=established,related out-interface-list=OVPN dst-address=10.250.60.0/24 place-before=[find where comment="OVPN: deny other forwarding"] comment="OVPN: return traffic"

The internal hosts must have a return path to 10.250.60.0/24. If this MikroTik is their gateway, no extra return route is needed. Otherwise, add that route on the actual LAN gateway via the MikroTik's reachable LAN address. Routed LAN access normally does not require masquerade.

Export the Client Certificate and Encrypted Key

Export only the public CA certificate and the user's certificate/key. Supplying an export passphrase encrypts the exported private key. Use a different passphrase from the VPN account password.

/certificate export-certificate vpn-root-ca type=pem file-name=vpn-ca
/certificate export-certificate vpn-client-user01 type=pem file-name=user01 export-passphrase="REPLACE_WITH_KEY_PASSPHRASE"
/file print where name~"^(vpn-ca|user01)"

Example output, shortened:

NAME TYPE
vpn-ca.crt .crt file
user01.crt .crt file
user01.key .key file

Download these three files through WinBox → Files. The CA private key and server private key are not needed on client devices. After securely assembling and transferring the profile, remove the exported client key file from the router's Files list; this does not delete the installed certificate.

Build the user01.ovpn Profile

Create user01.ovpn as a plain UTF-8 text file. Replace each placeholder with the complete corresponding file contents, including the PEM BEGIN/END lines. Keep the XML-style ca/cert/key tags.

client
dev tun
proto udp4
remote 203.0.113.10 1194

resolv-retry infinite
nobind
persist-key
persist-tun

auth-user-pass
remote-cert-tls server
verify-x509-name vpn.example.net name
tls-version-min 1.2

cipher AES-256-GCM
auth SHA256

tun-mtu 1400
ping 10
ping-restart 60
verb 3

<ca>
PASTE COMPLETE CONTENTS OF vpn-ca.crt
</ca>

<cert>
PASTE COMPLETE CONTENTS OF user01.crt
</cert>

<key>
PASTE COMPLETE CONTENTS OF user01.key
</key>

Import the profile into OpenVPN Connect. Enter user01 and the PPP password when connecting. If asked for a Private Key Password, enter the export passphrase from the previous step. Connecting by IP does not require DNS resolution for vpn.example.net; that name is checked against the server certificate.

Verify the Connection

Test from a different internet connection, such as mobile data. Check the assigned address and active tunnel on the router.

/ppp active print detail where service=ovpn
/interface ovpn-server print

Example output, shortened:

name="user01" service=ovpn caller-id="198.51.100.25"
address=10.250.60.10 uptime=2m15s

Flags: D - DYNAMIC; R - RUNNING
DR name="<ovpn-user01>" user="user01"

On Windows, inspect the route table and test a reachable LAN host. The two internal routes should use the VPN; the ordinary default route should remain local.

route print -4
ping 192.168.40.10

Example output, shortened:

Network Destination Netmask Interface
192.168.40.0 255.255.255.0 10.250.60.10
192.168.50.0 255.255.255.0 10.250.60.10

If the tunnel connects but a LAN service does not respond, check forwarding rules, the LAN return route and the destination host's firewall. Pushed routes select paths; firewall rules control access.

Optional: Full Tunnel and Internet Masquerade

To send the client's IPv4 internet traffic through MikroTik, push a default-route override. Set DNS servers for the PPP profile and allow VPN-to-WAN forwarding before the scoped VPN drop rule.

/interface ovpn-server server set [find where name="vpn-udp"] redirect-gateway=def1
/ppp profile set [find where name="vpn-users"] dns-server=9.9.9.9,149.112.112.112
/ip firewall filter add chain=forward action=accept in-interface-list=OVPN src-address=10.250.60.0/24 out-interface-list=WAN place-before=[find where comment="OVPN: deny other forwarding"] comment="OVPN: VPN to Internet"

In IP → Firewall → NAT, add a srcnat rule for the VPN subnet with Out. Interface List = WAN and Action = masquerade:

/ip firewall nat add chain=srcnat src-address=10.250.60.0/24 out-interface-list=WAN action=masquerade comment="OVPN: Internet NAT"
/ip firewall nat print where comment="OVPN: Internet NAT"

Example output, shortened:

chain=srcnat action=masquerade src-address=10.250.60.0/24
out-interface-list=WAN

Use this dedicated NAT rule if an existing WAN masquerade rule does not already cover the VPN subnet. Place it before any conflicting srcnat rule. Reconnect the client and confirm that its public IPv4 address is now the VPN site's public egress address.

This setup tunnels IPv4 only. Native client IPv6 traffic is not redirected by def1; disable/block it on the client or configure IPv6 tunneling separately when all internet traffic must use the VPN.

To return to split tunneling, stop pushing the default-route override and disable the optional internet-forwarding/NAT rules. The two LAN routes remain pushed:

/interface ovpn-server server set [find where name="vpn-udp"] redirect-gateway=disabled
/ppp profile set [find where name="vpn-users"] dns-server=""
/ip firewall filter disable [find where comment="OVPN: VPN to Internet"]
/ip firewall nat disable [find where comment="OVPN: Internet NAT"]

Reconnect the client. Its internet traffic will again use the local connection, while the listed internal networks remain accessible through OpenVPN.

Add Another User

Repeat the client-certificate and account steps with a new name and unique credentials. For example:

/ppp secret add name=user02 password="REPLACE_WITH_ANOTHER_VPN_PASSWORD" service=ovpn profile=vpn-users
/certificate add name=vpn-client-user02 common-name=user02 key-size=2048 digest-algorithm=sha256 days-valid=1827 key-usage=digital-signature,key-encipherment,tls-client
/certificate sign vpn-client-user02 ca=vpn-root-ca name=vpn-client-user02
/certificate export-certificate vpn-client-user02 type=pem file-name=user02 export-passphrase="REPLACE_WITH_ANOTHER_KEY_PASSPHRASE"

Build user02.ovpn with the same public CA and server directives, replacing the cert/key blocks with user02.crt and user02.key. The shared client pool supports multiple accounts; repeat with user03 and additional users as needed.

References

MikroTik OpenVPN documentation · Certificate management · PPP profiles · NAT