Base de Reseau VPN
Base de Reseau VPN
Base de Reseau VPN
ChatGPT
ChatGPT
Configurer un VPN sur un routeur MikroTik peut être un processus détaillé mais faisable.
Voici un guide étape par étape pour configurer un VPN sur un routeur MikroTik, en utilisant
le protocole OpenVPN comme exemple :
1. Téléchargez les fichiers nécessaires : Obtenez les fichiers de configuration OpenVPN de votre
fournisseur VPN. Ils incluent souvent des fichiers .ovpn, des certificats et des clés.
sql
Copier le code
/interface ovpn-client add name=vpn-client mode=ip user="your-
username" password="your-password" connect-to=your-vpn-server
5. Vérification de la configuration :
o Redémarrez le routeur pour appliquer les modifications et vérifiez l'état de la
connexion VPN pour vous assurer qu'elle est établie.
Remarques supplémentaires :
Ce guide devrait vous fournir une base solide pour configurer un VPN sur un routeur
MikroTik en utilisant OpenVPN. Les détails exacts peuvent varier en fonction de la version
du firmware et des spécifications de votre réseau ou de votre fournisseur VPN.
vpn sur mikrotik
ChatGPT
ChatGPT
Configurer un VPN sur un routeur MikroTik peut se faire en utilisant plusieurs protocoles,
notamment OpenVPN, L2TP/IPsec, PPTP, et SSTP. Voici un guide général pour configurer
les deux protocoles les plus courants : OpenVPN et L2TP/IPsec.
4. Activez la connexion :
o Appliquez les modifications et vérifiez l'état de la connexion L2TP/IPsec dans
l'interface PPP.
Remarques supplémentaires :
Sécurité et gestion des clés : Assurez-vous de sécuriser les certificats et les clés utilisés dans
vos configurations VPN.
Tests et dépannage : Vérifiez toujours la connectivité après la configuration et utilisez les
outils de débogage MikroTik pour résoudre tout problème éventuel.
Mise à jour du firmware : Assurez-vous que votre routeur MikroTik exécute la dernière
version du firmware pour des performances optimales et des fonctionnalités étendues.
Suivez ces étapes pour configurer avec succès un VPN sur votre routeur MikroTik, que ce soit
avec OpenVPN ou L2TP/IPsec. Les spécificités peuvent varier en fonction de votre
configuration réseau et des exigences de votre fournisseur VPN.
MikroTik OpenVPN Configuration
HamidReza S.
Ingénieur Core Os
1 février 2022
MicroTik OpenVPN est une solution VPN incroyable. Le service informatique fournit
un tunnel VPN sécurisé et crypté sur le réseau public. Contrairement aux services VPN
PPTP et L2TP qui sont mal conçus et peuvent facilement être bloqués, OpenVPN peut
être hautement personnalisé et peut même être exécuté sur le port TCP 443 si
populaire. Ainsi, OpenVPN ne peut pas être facilement bloqué. OpenVPN utilise des
certificats SSL/TLS. Ainsi, OpenVPN Tunnel est un tunnel de confiance pour envoyer
et recevoir des données sur le réseau public. OpenVPN est une technologie VPN de
site à site par nature, même dans le réseau NAT. Mais MikroTik OpenVPN a des
limites pour utiliser le nom d’utilisateur et le mot de passe PPP, bien qu’un VPN site à
site ne nécessite pas de nom d’utilisateur et de mot de passe.
Le but de cet article est de configurer un serveur OpenVPN sur le si populaire port
TCP 443 dans le routeur MikroTik et de configurer le client OpenVPN dans le système
d’exploitation Windows afin qu’un utilisateur Windows puisse se connecter à un
réseau de bureau distant et puisse accéder en toute sécurité aux ressources réseau
distantes (serveurs, imprimantes, etc.) sur le réseau public.
Diagramme de réseau
Pour configurer le serveur OpenVPN dans le routeur MikroTik sur le port TCP 443,
nous suivons le schéma de réseau ci-dessous.
Dans ce réseau, le routeur MikroTik (RouterOS v6.49) est connecté à Internet via
l’interface ether1 ayant l’adresse IP 117.58.247.198/30. Dans votre réseau, cette
adresse IP doit être remplacée par une adresse IP publique. L’interface ether2 du
routeur MikroTik est connectée au réseau local ayant un réseau IP 10.10.11.0/24.
Nous allons configurer le serveur OpenVPN dans ce routeur et le client OpenVPN
dans un système d’exploitation Windows. Après la configuration du serveur OpenVPN
et du client, le routeur créera une interface virtuelle (tunnel OpenVPN) sur le réseau
public où l’adresse IP de la passerelle VPN sera 192.168.2.1 et la machine cliente
obtiendra une adresse IP dans le bloc IP 192.168.2.0/24. Nous déclarerons également
la route dans le client OpenVPN afin que l’utilisateur VPN connecté puisse accéder
aux ressources du réseau du serveur OpenVPN.
According to the network diagram, MikroTik Router is our OpenVPN Server. So, we
will enable and configure OpenVPN Server in MikroTik Router. It is assumed that your
WAN and LAN networks are working without any issue.
Complete MikroTik OpenVPN Server configuration can be divided into the following
three steps.
OpenVPN server and client configuration requires TLS certificate because OpenVPN
uses TLS certificate for secure communication. MikroTik RouterOS v6 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 require three
types of certificates:
Creating CA certificate
The following steps will show how to create CA certificate in MikroTik RouterOS.
From Winbox, go to System > Certificates menu item 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 those if you wish. All fields are
self-defined.
Click on Key Usage tab and uncheck all checkboxes except crl sign and key cert. sign
checkboxes.
Click on Apply button and then click on Sign button. Sign window will appear now.
Your created CA 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 (example: 117.58.247.198) in CA CRL Host input field.
Click on Sign button. Your Signed 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, 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.
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 in CA certificate, put them here also.
Click on Key Usage tab and uncheck all checkboxes except digital signature, key
encipherment and tls server checkboxes.
Click on Apply button and then click on Sign button. Sign window will appear now.
Your newly created Server certificate template will appear in certificate dropdown menu.
Select newly created certificate template if it is not selected.
Also select CA certificate from CA dropdown menu.
Click on Sign button. Your Signed 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, 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.
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 put any optional field in CA certificate, put them here also.
Click on Key Usage tab and uncheck all checkboxes except tls client checkbox.
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 Signed 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. Created and signed CA, Server and
Client certificates will look like the following image in Certificates window.
After creating and signing CA, Server and Client certificates, we will now export CA
and Client certificates because OpenVPN client will use these certificates.
Select and make Right Click on your CA certificate and then click on Export option. Export
window will appear.
Choose CA certificate from Certificate dropdown menu.
Click on Export button now. Your CA certificate will be exported and Export window will be
closed.
Similarly, select and make right click on Client certificate and then click on Export option.
Choose client certificate from Certificate dropdown menu. Put a password in Export
Passphrase input field. The password should be strong enough and must remember because
the password has to provide when OpenVPN client will be connected. Click on Export button
now.
ٍExported CA and Client certificates with key will be found in Winbox File List
window. The following steps will show how to download exported certificates file
from File directory.
Click on Files menu from Winbox menu panel. You will find two certificate files (.crt) and one
key file (.key) is 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.
TLS certificates for OpenVPN Server and Client are ready. Now we will configure our
OpenVPN Server in MikroTik Router.
After creating TLS certificate, we are now eligible to enable and configure OpenVPN
Server in MikroTik Router. The following steps will show how to enable and configure
OpenVPN Server in MikroTik Router.
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 to enable OpenVPN Server.
Put your desired TCP Port (example: 443) on which you want to run OpenVPN Server in Port
input field.
Make sure ip option is selected in Mode dropdown menu.
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.
MikroTik OpenVPN uses username and password to validate legal connection. So, we
have to create username and password to allow any user. The complete user
configuration for OpenVPN Server can be divided into three parts.
IP Pool Configuration
User Profile Configuration and
User Configuration
IP Pool Configuration
Usually multiple users can connect to OpenVPN Server. So, it is always better to
create an IP Pool from where connected user will get IP address. The following steps
will show how to create IP Pool in MikroTik Router.
From Winbox, go to IP > Pool menu item. IP Pool Window will appear.
Click on PLUS SIGN (+). New IP Pool window will appear.
Put a meaningful name (vpn_pool) in Name input field.
Put desired IP Ranges (192.168.2.2-192.168.2.250) in Addresses input filed. Make sure not to
use VPN Gateway IP (192.168.2.1) and the last IP (192.168.2.154) because last IP will be used
as DHCP Server IP.
Click Apply and OK button.
After creating IP Pool, we will now configure profile so that all users can have similar
characteristics. The following steps will show how to configure user profile for
OpenVPN User.
From Winbox, go to PPP menu item and click on Profile tab and then click on PLUS SIGN (+).
New PPP Profile window will appear.
Put a meaningful name (vpn_profile) in Name input field.
Put VPN Gateway address (192.168.2.1) in Local Address input field.
Choose the created IP Pool (vpn_pool) from Remote Address dropdown menu.
Click Apply and OK button.
OpenVPN Users Configuration
After creating user profile, we will now create users who will be connected to
OpenVPN Server. The following steps will show how to create OpenVPN users in
MikroTik RouterOS.
From PPP window, click on Secrets tab and then click on PLUS SIGN (+). New PPP Secret
window will appear.
Put username (For example: sayeed) in Name input field and put password in Password input
field.
Choose ovpn from Service dropdown menu.
Choose the created profile from Profile dropdown menu.
Click on Apply and OK button.
We have created a user for OpenVPN Server. Similarly you can create more users that
you require.
OpenVPN Server configuration in MikroTik Router has been completed. In the next
part we will configure OpenVPN client in Windows Operating System.
After getting OpenVPN Client installer, install OpenVPN client in your operating
system following the instructions. Installation process is as simple as installing other
software in Windows operating system.
After OpenVPN Client installation, make sure that TAP Virtual Ethernet Adapter has
been installed. If it is installed successfully, you will find a new Network Adapter
named as TAP-Windows Adapter in Network Connections window.
Step 2: OpenVPN Client Configuration
Download OpenVPN Client Configuration File which has been prepared for this
article configuration and cross check with your configuration file.
Copy this sample configuration file into config folder and then open the client
configuration file with a text editor such as WordPad, NotePad ++ or any editor that
you like. Make sure the editor is opened with administrator privilege otherwise you
cannot save the file when you make change.
In the client.ovpn file, some parameters are required to change according to our
OpenVPN Server configuration. The following parameters are required to change in
client configuration file.
Protocol
By default OpenVPN client uses UDP protocol but MikroTik OpenVPN Server
supports only TCP protocol. So, enable proto tcp and disable proto udp which may
be found at line 36 and 37.
Note: To disable any option just put a semicolon (;) before that option and to enable
any option remove the semicolon (;) from that option.
IP and Port
We must specify OpenVPN Server IP and Port in Client configuration file. IP and Port
are declared with remote option which may be found at line 42 and the IP and Port
should be declared in a line like below. Make sure to change your WAN IP with the
example IP (117.58.247.198) and port (443) with your define port.
SSL/TLS Parameters
In client configuration file, we need to declare CA and Client certificates and Client
Key file. These options may be found at line 88, 89 and 90. So, assign ca, cert and key
file like below.
ca CA.crt
cert Client.crt
key Client.key
Make sure to rename exported and downloaded ca, client and key file according to
the above options and then copy your renamed CA.crt, Client.crt and Client.key files
into config directory.
We are not using any server key file. So we have to disable tls-auth option which is
enabled by default. The tls-auth option may be found at line 108. So, disable this
option by putting a semicolon (;) before it.
There are some options those we need to declare in client configuration file because
by default these options are not included in sample configuration file but MikroTik
Router requires those options. The following options are required to include in client
configuration to work with MikroTik OpenVPN Server properly.
User Authentication
auth-user-pass secret.cfg
Now create a file named secret.cfg in config directory and specify username and
password in this file. Username must be declared at the first line and password must
be declared at the second line like below.
sayeed
password
Routing Information
By default OpenVPN Client will only be able to communicate with the same network
IP Addresses. But remote network resources (Servers, Printers etc.) may have another
network. In this case we have to declare routing with route option otherwise
OpenVPN Client cannot reach to other network.
For example, Our VPN Gateway Address is 192.168.2.1 and Server network is
10.10.11.0/24. So, to reach this network we have to add route option like below.
If you have multiple networks, you have to add multiple route options but each route
option per line.
After coping CA.crt, Cleint.crt, Client.key and client.ovpn files, your config directory
will look like the below image.
Vous pourrez désormais accéder aux ressources de votre bureau distant telles que le
serveur de fichiers, les imprimantes, etc. sans aucun problème.
Remarque : Si vous souhaitez avoir accès à Internet via le canal VPN, vous devez créer
une règle NAT.