Создание сертификатов и ключей подписи для сервера и клиента
Сертификаты будем создавать на машине c win10. Скачиваем сам OpenVPN (в моем случае это версия 2.4.6) для генерации сертификатов.
Важно, при установке выбрать все галочки.
Открываем папку “C:Program filesOpenVPNeasy-rsa“, запускаем init-config.bat, появится файл vars.bat.sample, открываем его и редактируем такие строки:
set KEY_COUNTRY=BY
set KEY_PROVINCE=GomelRegion
set KEY_CITY=Gomel
set KEY_ORG=VTelecom
set KEY_EMAIL=disnetern@disnetern.ru
set KEY_CN=server
set KEY_NAME=server
set KEY_OU=disnetern
Эти параметры оставить неизменными “Key_CN” и “Key_NAME”, остальные можно вписать произвольно. Сохраняем как vars.bat в сваю домашнюю папку (в текущую не разрешат права), а потом перемещаем этот файл в “C:Program filesOpenVPNeasy-rsa” с подтверждением замены.
Теперь открываем openssl-1.0.0.cnf и выставляем параметр default_days=3650 (3650= это 10 лет, можете выставить нужное время истекания сертификата по своему усмотрению ).
Теперь открываем CMD от имени администратора и пишем поочередно команды:
cd C:Program FilesOpenVPNeasy-rsa
vars.bat
clean-all.bat
«Скопировано файлов: 1». Значит, процедура успешна. Если выдало сообщение ” vars.bat не является внутренней или внешней командой, исполняемой программой или пакетным файлом.” То отредактируйте в этом файле правильные, полные пути до команды.
Далее поочередно вбиваем команды для создания ключей:
build-dh
build-ca
Если опять выдало сообщение об ошибке – редактируем полный путь до команды openssl. (В моем случает нужно было указать полный адрес с пробелом, указав его в двойных кавычках). Все вопросы подтверждаем Enter. Дальше набираем:
build-key-server server
Все вопросы подтверждаем Enter, а на последние два соглашаемся “Y”
Далее создаем сертификат клиента:
build-key client
При ошибке, редактируем путь. На вопрос Common Name – ввести client. В конце два раза подтвердить “Y”.
С сертификатами готово. Забираем их из папки C:Program FilesOpenVPNeasy-rsakeys : ca.crt, server.crt, server.key
Настройка сервера OpenVPN на mikrotik
Заливаем файлы сертификатов и ключа на роутер Mikrotik, где будем настраивать сервер.
Далее произведём импорт сертификатов, System – Certificates, выбираем поочередно сертификаты из списка ca.crt, server.crt, server.key и жмём кнопку Import:
Создаём новый пул IP адресов для наших клиентов OpenVPN. IP -> Pool, добавили диапазон, например, 172.16.244.10-172.16.244.50, и назвал пул OVPN-pool
Далее создаём PPP профиль. PPP -> Profiles-> вводим имя профиля, локальный адрес роутера, в моем случае 172.16.244.1, с созданным пулом адресов OVPN-pool, остальные настройки выставляем по желанию.
Далее настраиваем сам OpenVPN сервер, PPP->Interface->OVPN Server, ставим Enabled, выбираем нужный порт, mode выставляем ip, выбираем созданный ранее профиль, ставим Require Client Certificate и выбираем сертификат server, остальные параметры по желанию.
Создадим пользователя, переходим в раздел PPP -> Secrets, вводим имя пользователя, пароль, указываем сервис и профиль.
Так как используются сертификаты, необходимо что бы время на сервере и на клиенте совпадало, для этого настраиваем ntp клиент и временную зону на роутере в разделе- System ->Clock/NTP Client. Адреса для NTP клиента можно взять, например, здесь.
Еще не забудьте настроить Ваш фаерфол для разрешения порта для OVPN, IP -> Firewall->Filter Rules
Теперь можно подключаться к нашему OVPN серверу.
Настройка Mikrotik в качестве клиента OpenVPN сервера
Сначала необходимо добавить сертификаты клиента на роутер (client.crt и client.key). Не передавайте никому закрытый ключ сертификата – “ca.key”, имея его можно создавать сертификаты подписанные данным ключом.
Делаем импорт сертификатов, идём в раздел System – Certificates, выбираем поочередно сертификаты client.crt->client.key.
Само соединение OpenVPN настраивается в меню PPP-> добавить OVPN Client
Указываем адрес сервера, логин/пароль, порт, клиентский сертификат и тип шифрования:
VPN (Virtual Private Network) technology provides a secure and encrypted tunnel across a public network. So, a private network user can send and receive data to any remote private network through VPN tunnel as if his/her network device was directly connected to that private network.
MikroTik OpenVPN Server provides a secure and encrypted tunnel across public network for transporting IP traffic using PPP. OpenVPN Server uses SSL Certificates. So, OpenVPN Tunnel is a trusted tunnel to send and receive data across public network. MikroTik OpenVPN Server can be applied in two methods.
Connecting remote workstation/client with OpenVPN: In this method, OpenVPN client software, installed any operating system such as Windows, can communicate with MikroTik OpenVPN server through OpenVPN tunnel whenever required and can access remote private network as if it was directly connected to the remote private network.
Site to Site OpenVPN: This method is also known as VPN between routers. In this method, an OpenVPN client supported router always establishes an OpenVPN tunnel with MikroTik OpenVPN Server. So, private networks of these routers can communicate with each other as if they were directly connected to the same router.
The goal of this article is to create a site to site OpenVPN Tunnel across public network. So, in this article I will show how to configure OpenVPN Tunnel between two MikroTik RouterOS so that local networks of these routers can communicate with each other as if they were directly connected to the same router.
Network Diagram
To configure a site to site OpenVPN Tunnel between two MikroTik RouterOS, I am following a network diagram like below image.
Site to Site OpenVPN Tunnel
In this network, Office1 Router is connected to internet through ether1 interface having IP address 192.168.70.2/30. In your real network, this IP address should be replaced with public IP address. Office1 Router’s ether2 interface is connected to local network having IP network 10.10.11.0/24. We will configure OpenVPN Server in this router and after OpenVPN configuration the router will create a virtual interface (OVPN Tunnel) across public network whose IP address will be 172.22.22.1.
On the other hand, Office2 Router is a remote router and can access Office1 Router’s WAN IP. Office2 Router’s ether1 interface is connected to internet having IP address 192.168.40.2/30 and ether2 has a local IP network 10.10.12.0/24. We will configure OpenVPN client in this router and after OpenVPN client configuration the router will have a virtual interface (OVPN Tunnel) across public network whose IP address will be 172.22.22.2.
Core Devices and IP Information
To configure a site to site OpenVPN between two Routers, I am using two MikroTik RouterOSv6.38.1. IP information that I am using for this network configuration are given below.
Office 1 Router WAN IP: 192.168.70.2/30, LAN IP Block 10.10.11.0/24 and Tunnel interface IP 172.22.22.1/30
Office 2 Router WAN IP: 192.168.80.2/30, LAN IP Block 10.10.12.0/24 and Tunnel interface IP 172.22.22.2/30
This IP information is just for my RND purpose. Change this information according to your network requirements.
Site to Site OpenVPN Configuration
We will now start Site to Site OpenVPN configuration with MikroTik Router according to the above network diagram. Complete site to site OpenVPN configuration can be divided into two parts.
Part 1: Office1 Router Configuration for OpenVPN Server
Part 2: Office2 Router Configuration for OpenVPN Client
Part 1: Office1 Router Configuration for OpenVPN Server
We will configure OpenVPN Server in Office1 RouterOS. Complete RouterOS configuration for OpenVPN Server can be divided into four steps.
Step 1: MikroTik RouterOS basic configuration
Step 2: Creating SSL certificate for OpenVPN server
Step 3: OpenVPN Server configuration
Step 4: PPP Secret creation for OpenVPN
Step 1: MikroTik RouterOS Basic Configuration
In MikroTik RouterOS basic configuration, we will assign WAN, LAN and DNS IP and perform NAT and Route configuration. The following steps will show how to do these topics in your RouterOS.
Login to MikroTik RouterOS using winbox and go to IP > Addresses. In Address List window, click on PLUS SIGN (+). In New Address window, put WAN IP address (192.168.70.2/30) in Address input field and choose WAN interface (ether1) from Interface dropdown menu and click on Apply and OK button. Click on PLUS SIGN again and put LAN IP (10.10.11.1/24) in Address input field and choose LAN interface (ether2) from Interface dropdown menu and click on Apply and OK button.
Go to IP > DNS and put DNS servers IP (8.8.8.8 or 8.8.4.4) in Servers input field and click on Apply and OK button.
Go to IP > Firewall and click on NAT tab and then click on PLUS SIGN (+). Under General tab, choose srcnat from Chain dropdown menu and click on Action tab and then choose masquerade from Action dropdown menu. Click on Apply and OK button.
Go to IP > Routes and click on PLUS SIGN (+). In New Route window, click on Gateway input field and put WAN Gateway address (192.168.70.1) in Gateway input field and click on Apply and OK button.
Basic RouterOS configuration has been completed. Now we will Create SSL certificate for OpenVPN Server.
Step 2: Creating SSL certificate for OpenVPN Server
OpenVPN Server configuration requires SSL certificate because OpenVPN uses SSL certificate for secure communication. MikroTik RouterOS version 6 gives ability to create, store and manage certificates in certificate store. So, we will create required OpenVPN certificate from our RouterOS. OpenVPN Server requires the following certificates:
CA (Certification Authority) certificate and
Server certificate
Creating CA certificate
The following steps will show how to create CA certificate in MikroTik RouterOS.
Go to System > Certificates menu item from winbox and click on Certificates tab and then click on PLUS SIGN (+). New Certificate window will appear.
Put your CA certificate name (for example: ca) in Name input field. Also put a certificate common name (for example: ca) in Common Name input field.
You will find some optional fields in General tab. You can fill if you wish. All fields are self-defined.
Click on Key Usage tab and uncheck all checkboxes except crl sign and key cert. sign
Click on Apply button and then click on Sign button. Sign window will appear now.
Your newly created certificate template will appear in certificate dropdown menu. Select your newly created certificate template if it is not selected.
Put MikroTik Router’s WAN IP address (192.168.70.2) in CA CRL Host input field.
Click on Sign button. Your Sign certificate will be created within few seconds.
Click on OK button to close New Certificate window.
If newly created CA certificate does not show T flag or Trusted property shows no value, double click on your CA certificate and click on Trusted checkbox located at the bottom of General tab and then click on Apply and OK button.
CA certificate has been created successfully. Now we will create server certificate.
Creating Server Certificate
The following steps will show how to create server certificate in MikroTik RouterOS.
Click on PLUS SIGN (+) again. New Certificate window will appear.
Put your server certificate name (for example: server) in Name input field. Also put a certificate common name (for example: server) in Common Name input field.
If you have put any optional field for CA certificate, put them here also.
Click on Key Usage tab and uncheck all checkboxes.
Click on Apply button and then click on Sign button. Sign window will appear now.
Your newly server created certificate template will appear in certificate dropdown menu. Select your newly created certificate template if it is not selected.
Also select CA certificate from CA dropdown menu.
Click on Sign button. Your Sign certificate will be created within few seconds.
Click on OK button to close New Certificate window.
If newly created server certificate does not show T flag or Trusted property shows no value, double click on your server certificate and click on Trusted checkbox located at the bottom of General tab and then click on Apply and OK button.
Server certificate has been created successfully. Now we will enable and configure OpenVPN Server in MikroTik RouterOS.
Step 3: OpenVPN Server Configuration in MikroTik Router
After creating SSL certificate, we are now eligible to enable OpenVPN Server in MikroTik Router. The following steps will show how to enable OpenVPN Server in your MikroTik Router with proper configuration.
Click on PPP menu item from winbox and then click on Interface tab.
Click on OVPN Server button. OVPN Server window will appear.
Click on Enabled checkbox.
From Certificate dropdown menu, choose server certificate that we created before.
From Auth. Panel, uncheck all checkboxes except sha1.
From Cipher panel, uncheck all checkboxes except aes 256.
Now click on Apply and OK button.
OpenVPN Server is now running in MikroTik Router. Now we will create OpenVPN user who will be connected to this server.
Step 4: PPP Secret creation for OpenVPN
After OpenVPN Server setup, we need to create OpenVPN user who will be connected to OpenVPN Server. OpenVPN Server uses PPP user for authentication. So, we will now create PPP secret (username and password) for OpenVPN client. The following steps will show how to create PPP secret in MikroTik Router.
Click on PPP menu item from winbox and then click on Secrets tab.
Click on PLUS SIGN (+). New PPP Secret window will appear.
Put username (For example: sayeed) in Name input and password in Password input field. This username and password will be required at the time of OpenVPN client configuration.
Choose ovpn from Service dropdown menu.
Put Office 1 Router’s virtual interface IP (172.22.22.1) in Local Address input field and put Office 2 Router’s virtual interface IP (172.22.22.2) in Remote Address input field.
Put static routes to reach Office2 Router’s local network in Routes input filed. This route will be added in Office1 Router’s routing table when OpenVPN user will be connected from Office2 Router. The route format is: dst-address gateway metric (example for this configuration: 10.10.12.0/24 172.22.22.2 1). Several routes may be specified separated with commas.
Click on Apply and OK button.
PPP user who will be connected from remote client machine has been created. Whenever your created user will be connected from OpenVPN client router (Office2 Router), the Remote Address IP will be assigned for its virtual interface and the routes will be created in Office1 Router’s routing table so that Office1 Router’s local network can reach remote router’s (Office2 Router) local network.
Office1 Router configuration for OpenVPN Server has been completed. Now Office1 Router is ready to create OpenVPN Tunnel for its OpenVPN user. In the next part, we will configure our Office2 Router so that it can connect to Office1 Router through OVPN Tunnel to reach Office1 Router’s local network.
Part 2: Office2 Router Configuration for OpenVPN Client
According to our network diagram, Office2 Router is working as an OpenVPN client router. So, we will configure OpenVPN client in Office2 Router. Complete RouterOS configuration can be divided into three steps.
Basic RouterOS Configuration
OpenVPN client configuration
Static route configuration
Step 1: Basic RouterOS Configuration
Basic RouterOS configuration includes assigning WAN, LAN and DNS IP as well as NAT and Route configuration. The following steps will guide you about basic RouterOS configuration.
Login to Office2 RouterOS using winbox and go to IP > Addresses. In Address List window, click on PLUS SIGN (+). In New Address window, put WAN IP address (192.168.80.2/30) in Address input field and choose WAN interface (ether1) from Interface dropdown menu and click on Apply and OK button. Click on PLUS SIGN again and put LAN IP (10.10.12.1/24) in Address input field and choose LAN interface (ether2) from Interface dropdown menu and click on Apply and OK button.
Go to IP > DNS and put DNS servers IP (8.8.8.8 or 8.8.4.4) in Servers input field and click on Apply and OK button.
Go to IP > Firewall and click on NAT tab and then click on PLUS SIGN (+). Under General tab, choose srcnat from Chain dropdown menu and click on Action tab and then choose masquerade from Action dropdown menu. Click on Apply and OK button.
Go to IP > Routes and click on PLUS SIGN (+). In New Route window, click on Gateway input field and put WAN Gateway address (192.168.80.1) in Gateway input field and click on Apply and OK button.
Basic RouterOS configuration in Office2 Router has been completed. Now it is time to create OpenVPN Client in our MikroTik Router.
Step 2: OpenVPN Client Configuration
After completing RouterOS basic configuration, we will now configure OpenVPN client in Office2 Router. The following steps will show you how to create OVPN client in your MikroTik Router.
Click on Interfaces menu item from winbox and then click on Interface tab. Click on PLUS SIGN (+) dropdown menu and then choose OVPN Client option. New Interface window will appear.
Click on General tab and put OpenVPN interface name (openvpn-server) in Name input field.
Click on Dial Out tab and put Office1 Router’s WAN IP (192.168.70.2) in Connect To input field. This IP must be reachable from Office2 Router.
Put username (sayeed) and password that you have provided in Office1 Router’s PPP user configuration, in User and Password input field respectively.
From dropdown menu, choose sha1 encryption method.
From Cipher dropdown menu, choose aes 256
Click on Apply and OK button.
As soon as you provide the above information, an OVPN Tunnel will be created between Office1 and Office2 Router and provided local and remote IP address will be assigned in office1 and Office2 Router’s virtual interface respectively. At this stage, Office1 Router as well as its local network will be able to reach Office2 Router and its local network but Office2 Router and its local network will only be able to reach Office1 Router but not its local network. To reach Office1 Router’s local network, a static route must be added in Office2 Router’s routing table.
Step 3: Static Route Configuration
After configuring OVPN Client in Office2 Router, Office 2 Router can only access Office 1 Router but not its local network. To solve this issue, a route is required in Office2 Router’s routing table. The following steps will show how to add a route in Office2 Router’s routing table statically.
Go to IP > Routes and then click on PLUS SIGN (+).
In New Route window, provide Office1 Router’s local network (10.10.11.0/24) where you want to reach, in Dst. Address input field.
Click on Gateway input field and then choose OpenVPN client interface (openvpn-server) that you have created at the of OVPN client configuration, from Gateway dropdown menu.
Click on Apply and OK button.
Now Office 2 Router and its local network will be able to access Office 1 Router’s local network.
Office1 Router and Office2 Router Configuration for establishing an OVPN Tunnel between them has been completed. Now both router’s local networks are eligible to access each other. To check your configuration, do a ping request from any local network machine to other local network machine. If everything is OK, your ping request will be success.
MikroTik VPN Configuration with Site to Site OpenVPN Service has been explained in this article. I hope you will be able to configure your Site to Site VPN with MikroTik OpenVPN service if you follow the above explanation carefully. However, if you face any confusion to do above steps properly, feel free to discuss in comment or contact with me from Contact page. I will try my best to stay with you.
VPN (Virtual Private Network) technology provides a secure and encrypted tunnel across a public network. So, a private network user can send and receive data to any remote private network through VPN tunnel as if his/her network device was directly connected to that private network.
MikroTik OpenVPN Server provides a secure and encrypted tunnel across public network for transporting IP traffic using PPP. OpenVPN uses SSL Certificates. So, OpenVPN Tunnel is a trusted tunnel to send and receive data across public network. MikroTik OpenVPN Server can be applied in two methods.
Connecting remote workstation/client: In this method, OpenVPN client software installed any operating system such as Windows can communicate with MikroTik OpenVPN server through OpenVPN tunnel whenever required and can access remote private network as if it was directly connected to the remote private network.
Site to Site OpenVPN: This method is also known as VPN between routers. In this method, an OpenVPN client supported router always establishes an OpenVPN tunnel with MikroTik OpenVPN Server. So, private networks of these routers can communicate with each other as if they were directly connected to the same router.
The goal of this article is to connect a remote client using OpenVPN Tunnel across public network. So, in this article I will only show how to configure MikroTik OpenVPN Server for connecting a remote workstation/client (Windows Client).
Network Diagram
To configure a MikroTik OpenVPN Tunnel for connecting a remote workstation/client, I am following a network diagram like below image.
OpenVPN Remote Office Network
In this network, MikroTik Router (RouterOSv6.38.1) is connected to internet through ether1 interface having IP address 192.168.30.2/30. In your real network, this IP address should be replaced with public IP address. MikroTik Router’s ether2 interface is connected to local network having IP network 10.10.11.0/24. We will configure OpenVPN server in this router and after OpenVPN configuration the router will create a virtual interface (OpenVPN Tunnel) across public network whose IP address will be 10.10.11.1. On the other hand, a remote laptop (workstation/client) is connected to internet and wants to connect to our OpenVPN server for accessing local network resources. We will configure OpenVPN client in this laptop and after establishing an OpenVPN Tunnel across public network, this laptop will get a MikroTik Router’s local IP 10.10.11.10 and will be able to access MikroTik Router’s private network.
MikroTik OpenVPN Server Configuration
We will now start OpenVPN Server configuration. Complete OpenVPN configuration can be divided into two parts.
Part 1: OpenVPN Server Configuration in MikroTik Router
Part 2: OpenVPN Client Configuration in Windows OS
Part 1: OpenVPN Server Configuration in MikroTik Router
According to our network diagram, MikroTik Router is our OpenVPN Server. So, we will setup and configure OpenVPN Server in MikroTik Router. Complete MikroTik RouterOS configuration for OpenVPN Server can be divided into five steps.
Step 1: MikroTik Router basic configuration
Step 2: Creating SSL certificate for OpenVPN server and client
Step 3: OpenVPN Server configuration
Step 4: PPP Secret creation for OpenVPN client
Step 5: Enabling Proxy ARP on LAN interface
Step 1: MikroTik Router basic configuration
In MikroTik Router basic configuration, we will assign WAN, LAN and DNS IP and perform NAT and Route configuration. The following steps will show how to do these topics in your RouterOS.
Login to MikroTik RouterOS using winbox and go to IP > Addresses. In Address List window, click on PLUS SIGN (+). In New Address window, put WAN IP address (192.168.30.2/30) in Address input field and choose WAN interface (ether1) from Interface dropdown menu and click on Apply and OK button. Click on PLUS SIGN again and put LAN IP (10.10.11.1/24) in Address input field and choose LAN interface (ether2) from Interface dropdown menu and click on Apply and OK button.
Go to IP > DNS and put DNS servers IP (8.8.8.8 or 8.8.4.4) in Servers input field and click on Apply and OK button.
Go to IP > Firewall and click on NAT tab and then click on PLUS SIGN (+). Under General tab, choose srcnat from Chain dropdown menu and click on Action tab and then choose masquerade from Action dropdown menu. Click on Apply and OK button.
Go to IP > Routes and click on PLUS SIGN (+). In New Route window, click on Gateway input field and put WAN Gateway address (192.168.30.1) in Gateway input field and click on Apply and OK button.
Basic RouterOS configuration has been completed. Now we will Create SSL certificate for OpenVPN server and client.
Step 2: Creating SSL certificate for OpenVPN Server and Client
OpenVPN server and client configuration requires SSL certificate because OpenVPN uses SSL certificate for secure communication. MikroTik RouterOS version 6 gives ability to create, store and manage certificates in certificate store. So, we will create required OpenVPN certificate from our RouterOS. OpenVPN server and client configuration requires three types of certificates:
CA (Certification Authority) certificate
Server certificate and
Client certificate
Creating CA certificate
The following steps will show how to create CA certificate in MikroTik RouterOS.
Go to System > Certificates menu item from winbox and click on Certificates tab and then click on PLUS SIGN (+). New Certificate window will appear.
Put your CA certificate name (for example: ca) in Name input field. Also put a certificate common name (for example: ca) in Common Name input field.
You will find some optional fields in General tab. You can fill if you wish. All fields are self-defined.
Click on Key Usage tab and uncheck all checkboxes except crl sign and key cert. sign
Click on Apply button and then click on Sign button. Sign window will appear now.
Your newly created certificate template will appear in certificate dropdown menu. Select your newly created certificate template if it is not selected.
Put MikroTik Router’s WAN IP address (192.168.30.2) in CA CRL Host input field.
Click on Sign button. Your Sign certificate will be created within few seconds.
Click on OK button to close New Certificate window.
If newly created CA certificate does not show T flag or Trusted property shows no value, double click on your CA certificate and click on Trusted checkbox located at the bottom of General tab and then click on Apply and OK button.
CA certificate has been created successfully. Now we will create server certificate.
Creating Server Certificate
The following steps will show how to create server certificate in MikroTik RouterOS.
Click on PLUS SIGN (+) again. New Certificate window will appear.
Put your server certificate name (for example: server) in Name input field. Also put a certificate common name (for example: server) in Common Name input field.
If you have put any optional field for CA certificate, put them here also.
Click on Key Usage tab and uncheck all checkboxes except digital signature, key encipherment and tls server
Click on Apply button and then click on Sign button. Sign window will appear now.
Your newly server created certificate template will appear in certificate dropdown menu. Select your newly created certificate template if it is not selected.
Also select CA certificate from CA dropdown menu.
Click on Sign button. Your Sign certificate will be created within few seconds.
Click on OK button to close New Certificate window.
If newly created server certificate does not show T flag or Trusted property shows no value, double click on your server certificate and click on Trusted checkbox located at the bottom of General tab and then click on Apply and OK button.
Server certificate has been created successfully. Now we will create client certificate.
Creating Client Certificate
The following steps will show how to create client certificate in MikroTik RouterOS.
Click on PLUS SIGN (+) again. New Certificate window will appear.
Put your client certificate name (for example: client) in Name input field. Also put a certificate common name (for example: client) in Common Name input field.
If you have put any optional field for CA certificate, put them here also.
Click on Key Usage tab and uncheck all checkboxes except tls client
Click on Apply button and then click on Sign button. Sign window will appear now.
Your newly created client certificate template will appear in certificate dropdown menu. Select your newly created certificate template if it is not selected.
Also select CA certificate from CA dropdown menu.
Click on Sign button. Your Sign certificate will be created within few seconds.
Click on OK button to close New Certificate window.
Client certificate does not require T flag.
Client certificate has been created successfully. Now we will export CA and Client certificates so that OpenVPN client can use this certificate.
Exporting CA and Client Certificates
OpenVPN server will use server certificate from MikroTik RouterOS certificate store. But client certificate has to supply to the OpenVPN client. So, we need to export client certificate as well as CA certificate from RouterOS certificate store. The following steps will show how to export CA certificate and client certificate from MikroTik certificate store.
Click twice on your CA certificate and then click on Export button from right button panel. Export window will appear.
Choose your CA certificate from Certificate dropdown menu.
Click on Export button now. Your CA certificate will be exported and Export window will be closed. Your exported CA certificate will be stored in File List.
Again, click on Export button from right button panel and choose your client certificate from Certificate dropdown menu.
Put a password in Export Passphrase input field. The password must be at least 8 characters and this password has to provide when OpenVPN client will be connected.
Click on Export button now. Your client certificate and key file will be exported in File List.
Now click on Files menu from winbox left menu panel. You will find two certificate file (.crt) and one key (.key) are exported here.
Drag and Drop these three files in a folder on your Desktop. We will use these files when OpenVPN client will be configured.
Creating SSL certificate for OpenVPN server and client has been completed. Now we will configure our OpenVPN Server in MikroTik Router.
Step 3: OpenVPN Server Configuration in MikroTik Router
After creating SSL certificate, we are now eligible to enable OpenVPN Server in MikroTik Router. The following steps will show how to enable OpenVPN Server in your MikroTik Router with proper configuration.
Click on PPP menu item from winbox and then click on Interface tab.
Click on OVPN Server button. OVPN Server window will appear.
Click on Enabled checkbox.
From Certificate dropdown menu, choose server certificate that we created before. Also click on Require Client Certificate checkbox.
From Auth. Panel, uncheck all checkboxes except sha1.
From Cipher panel, uncheck all checkboxes except aes 256.
Now click on Apply and OK button.
OpenVPN Server is now running in MikroTik Router. Now we will create OpenVPN user who will be connected to this server.
Step 4: PPP Secret creation for OpenVPN client
After OpenVPN Server setup, we need to create OpenVPN user who will be connected to OpenVPN Server. OpenVPN Server uses PPP user for authentication. So, we will now create PPP secret (username and password) for OpenVPN client. The following steps will show how to create PPP secret in MikroTik Router.
Click on PPP menu item from winbox and then click on Secrets tab.
Click on PLUS SIGN (+). New PPP Secret window will appear.
Put username (For example: sayeed) in Name input and password in Password input field. This username and password will be required at the time of OpenVPN client configuration.
Choose ovpn from Service dropdown menu.
Put the gateway IP (10.10.11.1) in Local Address input field and put a LAN IP (10.10.11.10) that will be assigned in client workstation when this user will be connected, in Remote Address input field.
Click on Apply and OK button.
PPP user who will be connected from remote client machine has been created. At this point, if the user gets connected from the remote client machine and try to ping any workstation from the remote machine, the ping will time out because the remote client is unable to get ARPs from workstations. The solution is to set up proxy-arp on the LAN interface.
Step 4: Enabling Proxy ARP on LAN Interface
The following steps will show how to enable proxy-arp on the LAN interface.
Click on Interfacesmenu item from winbox and then click on interface tab.
Click twice on your LAN interface (ether2). Interface property window will appear.
Under General tab, choose proxy-arp from ARP dropdown menu.
Click Apply and OK button.
After enabling proxy-arp, the remote client can successfully reach all workstations in the local network behind the router.
MikroTik OpenVPN Server is now completely ready to accept OpenVPN client. So, we will now configure OpenVPN client in Windows Operating System.
Part 2: OpenVPN Client configuration in Windows OS
OpenVPN.net provides OpenVPN client software for all the operating systems. You can visit to download page and download your OpenVPN client that is matched with your system requirement. I am using Windows 7, 64-bit operating system. So, I have downloaded Installer (64-bit), Windows Vista and later package. At the time of this article, the OpenVPN client version was 2.3.18.
After downloading, install OpenVPN client in your operating system following the instruction. Installation process is as simple as installing other software in Windows operating system.
After OpenVPN client installation, go to configuration file location (by default: C:Program FilesOpenVPNconfig or C:Program Files (x86)OpenVPNconfig depending on your operating system) and follow my below steps to configure OpenVPN client.
Create a file having (.ovpn) extension (for example: client.ovpn) and copy and paste below property and its value in this file and then save your file.
#Template client.ovpnclient
dev tun
proto tcp-client
remote 192.168.30.2
port 1194
nobind
persist-key
persist-tun
tls-client
remote-cert-tls server
ca ca.crt
cert client.crt
key client.key
verb 4
mute 10
cipher AES-256-CBC
auth SHA1
auth-user-pass secret
auth-nocache
Here, change remote IP Address according to your MikroTik WAN IP.
Now copy and paste your exported CA and Client certificate files that you saved in your Desktop by dragging and dropping from MikroTik File List, in this location and rename CA file as ca.crt, client certificate file as client.crt and key file as client.key because we have used these names in our configuration file.
Create another file named secret (because we have put auth-user-pass file is secret) without any extension and put OpenVPN PPP username at first line and password in second line and then save this file.
Now run OpenVPN client software. You will find a new icon in your Taskbar or System tray like below image.
Click mouse right button on this icon and then click Connect option. OpenVPN Connection window will appear and it will ask to put your client certificate password that you have entered at the time of client certificate exportation.
If you put correct password and if everything is OK, your OpenVPN client will be connected and an OpenVPN tunnel will be created between OpenVPN client and server.To check your configuration, do a ping request to any remote network workstation or server. If everything is OK, your ping request will be success.
MikroTik OpenVPN Server configuration with Windows Client has been explained in this article. I hope you will be able to configure your OpenVPN Server and Client if you follow the explanation carefully. However, if you face any confusion to follow above steps properly, feel free to discuss in comment or contact with me from Contact page. I will try my best to stay with you.
Мне понадобилось использовать роутер mikrotik в качестве клиента openvpn с заменой шлюза по-умолчанию на сервер openvpn. Проще говоря мне нужно было скрыть весь трафик и направить его только через vpn сервер. В openvpn это реализуется очень просто, достаточно на сервере указать для конкретного пользователя параметр redirect-gateway def1. На клиенте под windows это без проблем работает. В микротике пришлось разбираться.
Настройка Firewall (ufw), при использовании openVPN… Симптомы, медленное подключение, задержки при обращении к DNS серверам.
***
Для начала разрешим SSH:
$ ufw allow ssh
Разрешим UDP:
$ ufw allow 1194/udp
Правим правила перенаправления:
$ nano /etc/default/ufw
DEFAULT_FORWARD_POLICY=»ACCEPT»
Правим правила трансляции IP:
$ nano /etc/ufw/before.rules
# rules.before # # Rules that should be run before the ufw command line added rules. Custom # rules should be added to one of these chains: # ufw-before-input # ufw-before-output # ufw-before-forward #
# START OPENVPN RULES # NAT table rules *nat :POSTROUTING ACCEPT [0:0] # Allow traffic from OpenVPN client to eth0 -A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE COMMIT # END OPENVPN RULES
Проверка статуса Firewall (ufw):
$ ufw status
Автор: AugustuS Karro
Дата публикации: 2015-07-06T09:34:00.000+07:00