<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
	<id>https://wikiold.home.tartarefr.eu/index.php?action=history&amp;feed=atom&amp;title=Services%2FVPN%2FOpenvpn</id>
	<title>Services/VPN/Openvpn - Historique des versions</title>
	<link rel="self" type="application/atom+xml" href="https://wikiold.home.tartarefr.eu/index.php?action=history&amp;feed=atom&amp;title=Services%2FVPN%2FOpenvpn"/>
	<link rel="alternate" type="text/html" href="https://wikiold.home.tartarefr.eu/index.php?title=Services/VPN/Openvpn&amp;action=history"/>
	<updated>2026-07-06T21:15:25Z</updated>
	<subtitle>Historique des versions pour cette page sur le wiki</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://wikiold.home.tartarefr.eu/index.php?title=Services/VPN/Openvpn&amp;diff=1814&amp;oldid=prev</id>
		<title>Didier : Page créée avec « &#039;&#039;&#039;How to install, setup and configure an OpenVPN Service on CentOS&#039;&#039;&#039;  == Introduction ==  In this tutorial, we will learn how to install, setup and configure an OpenVPN ... »</title>
		<link rel="alternate" type="text/html" href="https://wikiold.home.tartarefr.eu/index.php?title=Services/VPN/Openvpn&amp;diff=1814&amp;oldid=prev"/>
		<updated>2013-05-02T12:07:21Z</updated>

		<summary type="html">&lt;p&gt;Page créée avec « &amp;#039;&amp;#039;&amp;#039;How to install, setup and configure an OpenVPN Service on CentOS&amp;#039;&amp;#039;&amp;#039;  == Introduction ==  In this tutorial, we will learn how to install, setup and configure an OpenVPN ... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;#039;How to install, setup and configure an OpenVPN Service on CentOS&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
In this tutorial, we will learn how to install, setup and configure an OpenVPN Service on CentOS 5 as well as configuring the firewall to allow vpn traffic. Clients configuration will be done in the linked article, available at the bottom of this tutorial.&lt;br /&gt;
&lt;br /&gt;
Topology used in this scenario:&lt;br /&gt;
&lt;br /&gt;
* 1 Ethernet card (eth0) connected to a router, which forward all connection on port 1723 for UDP and TCP protocol to our server internal IP.&lt;br /&gt;
* Internet IP: 1.2.3.4&lt;br /&gt;
* Internal IP: 192.168.0.2&lt;br /&gt;
* Existing Subnet: 192.168.0.0/24&lt;br /&gt;
* New VPN Subnet: 172.16.0.0/24&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
=== Repositories ===&lt;br /&gt;
To begin, we need to make sure we have the RPMForge repository installed and activated.&lt;br /&gt;
&lt;br /&gt;
=== SELinux ===&lt;br /&gt;
If you have SELinux enabled and enforcing, you will need to run this:&lt;br /&gt;
&lt;br /&gt;
 semanage port -a -t openvpn_port_t -p tcp 1723&lt;br /&gt;
 semanage port -a -t openvpn_port_t -p udp 1723&lt;br /&gt;
&lt;br /&gt;
=== Install ===&lt;br /&gt;
Install OpenVPN via yum. This will make sure that the following package are installed: openvpn, lzo, pkcs11-helper&lt;br /&gt;
&lt;br /&gt;
 yum install openvpn&lt;br /&gt;
&lt;br /&gt;
=== Keys datadir ===&lt;br /&gt;
&lt;br /&gt;
Copy the easy-rsa directory from the template to your /etc/openvpn (please change the version number according to your version of openvpn)&lt;br /&gt;
&lt;br /&gt;
 cd /etc/openvpn/&lt;br /&gt;
 cp -R /usr/share/doc/openvpn-2.2.2/easy-rsa/ /etc/openvpn/&lt;br /&gt;
 cd /etc/openvpn/easy-rsa/2.0/&lt;br /&gt;
 chmod +rwx *&lt;br /&gt;
&lt;br /&gt;
==== SSL Configuration ====&lt;br /&gt;
&lt;br /&gt;
Edit the configuration file &amp;lt;path&amp;gt;/etc/openvpn/easy-rsa/2.0/vars&amp;lt;/path&amp;gt; with your favorite editor, and change the values at the complete bottom to correspond with your own informations and make sure you save a copie somewhere. (from KEY_COUNTRY up to KEY_OU)&lt;br /&gt;
&lt;br /&gt;
File &amp;lt;path&amp;gt;/etc/openvpn/easy-rsa/2.0/vars&amp;lt;/path&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
KEY_COUNTRY=&amp;quot;CA&amp;quot;&lt;br /&gt;
KEY_PROVINCE=&amp;quot;QC&amp;quot;&lt;br /&gt;
KEY_CITY=&amp;quot;Montreal&amp;quot;&lt;br /&gt;
KEY_ORG=&amp;quot;CompanyName&amp;quot;&lt;br /&gt;
KEY_EMAIL=&amp;quot;your@email.com&amp;quot;&lt;br /&gt;
KEY_EMAIL=your@email.com&lt;br /&gt;
KEY_CN=server.hostname.com&lt;br /&gt;
KEY_NAME=server.hostname.com&lt;br /&gt;
KEY_OU=OrganisationUnitName&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Create Certificate authority and keys ====&lt;br /&gt;
&lt;br /&gt;
Source the configuration file `vars` with the following command and clean-all&lt;br /&gt;
&lt;br /&gt;
 source /etc/openvpn/easy-rsa/2.0/vars&lt;br /&gt;
 /etc/openvpn/easy-rsa/2.0/clean-all&lt;br /&gt;
&lt;br /&gt;
Once we reach this step, openvpn has been installed and initially configured. Now we have to build our CA Certificate, our Server Certificate and our Client Certificate.&lt;br /&gt;
&lt;br /&gt;
Start by building the CA Certificate with the command:&lt;br /&gt;
&lt;br /&gt;
 /etc/openvpn/easy-rsa/2.0/build-ca&lt;br /&gt;
&lt;br /&gt;
This step will ask your information for the CA Certificate Authority that we are creating, if we configured the `vars` configuration file in step 6, the default values provided between ‘[&amp;#039; and &amp;#039;]‘ for each value should be fine. Otherwise change accordingly.&lt;br /&gt;
&lt;br /&gt;
It is time now to create the Server Certificate with our newly created CA Authority Certificate. Run the following command (and replace `server.hostname.com` with your server hostname):&lt;br /&gt;
&lt;br /&gt;
 /etc/openvpn/easy-rsa/2.0/build-key-server server.hostname.com&lt;br /&gt;
&lt;br /&gt;
This will print a summary of the certificate to be created and ask you to confirm that you want to “Sign the certificate” which you will say YES ot ‘y’&lt;br /&gt;
Finally, it will ask you to confirm to commit the change, which again, you will say YES or ‘y’&lt;br /&gt;
&lt;br /&gt;
Create the DH and move it.&lt;br /&gt;
&lt;br /&gt;
This key prevent &amp;#039;&amp;#039;Man on the middle&amp;#039;&amp;#039; attacks.&lt;br /&gt;
 /etc/openvpn/easy-rsa/2.0/build-dh&lt;br /&gt;
 mv /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem /etc/openvpn/keys/&lt;br /&gt;
&lt;br /&gt;
== Server/Client configuration ==&lt;br /&gt;
&lt;br /&gt;
Now we have to edit our main configuration file at /etc/openvpn/openvpn.conf with our favorite editor,&lt;br /&gt;
(change server.hostname.com for the value used while building the server certificate at step 10)&lt;br /&gt;
&lt;br /&gt;
File &amp;lt;path&amp;gt;/etc/openvpn/openvpn.conf&amp;lt;/path&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
port 1723&lt;br /&gt;
proto udp # UDP is faster than TCP&lt;br /&gt;
dev tun&lt;br /&gt;
ca /etc/openvpn/keys/ca.crt&lt;br /&gt;
cert /etc/openvpn/keys/server.hostname.com.crt&lt;br /&gt;
key /etc/openvpn/keys/server.hostname.com.key&lt;br /&gt;
dh /etc/openvpn/keys/dh1024.pem&lt;br /&gt;
cipher BF-CBC&lt;br /&gt;
comp-lzo&lt;br /&gt;
server 172.16.0.0 255.255.255.0&lt;br /&gt;
push &amp;quot;dhcp-option DNS 4.2.2.2&amp;quot; # Change these to your own DNS Server for even greater security&lt;br /&gt;
push &amp;quot;dhcp-option DNS 4.2.2.1&amp;quot; # Change these to your own DNS Server for even greater security&lt;br /&gt;
ifconfig-pool-persist /etc/openvpn/ipp.txt&lt;br /&gt;
keepalive 10 120&lt;br /&gt;
persist-key&lt;br /&gt;
persist-tun&lt;br /&gt;
status openvpn-status.log&lt;br /&gt;
verb 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Create the directory to hold our created keys and certificates, make it private and move them into it:&lt;br /&gt;
&lt;br /&gt;
 mkdir /etc/openvpn/keys/&lt;br /&gt;
 chmod 0700 /etc/openvpn/keys/&lt;br /&gt;
 mv /etc/openvpn/easy-rsa/2.0/keys/{ca.crt,ca.key,server.hostname.com.crt,server.hostname.com.key} /etc/openvpn/keys/&lt;br /&gt;
&lt;br /&gt;
== Start the VPN ==&lt;br /&gt;
Make sure that the OpenVPN Service start at boot time&lt;br /&gt;
&lt;br /&gt;
 chkconfig openvpn on&lt;br /&gt;
&lt;br /&gt;
That it! The OpenVPN Service is now ready to be executed.&lt;br /&gt;
&lt;br /&gt;
 /etc/init.d/openvpn start&lt;br /&gt;
&lt;br /&gt;
== Firewall ==&lt;br /&gt;
&lt;br /&gt;
For the Firewall configuration, you need to run the following commands:&lt;br /&gt;
&lt;br /&gt;
 /sbin/iptables -A INPUT -d 1.2.3.4 -i eth0 -p udp -m udp --dport 1723 -j ACCEPT&lt;br /&gt;
 /sbin/iptables -A OUTPUT -s 1.2.3.4 -d 172.16.0.0/255.255.255.0 -o lo -j ACCEPT&lt;br /&gt;
 /sbin/iptables -A OUTPUT -s 1.2.3.4 -d 172.16.0.0/255.255.255.0 -o tun0 -j ACCEPT&lt;br /&gt;
 /sbin/iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT&lt;br /&gt;
 /sbin/iptables -A FORWARD -s 172.16.0.0/24 -j ACCEPT&lt;br /&gt;
 /sbin/iptables -A FORWARD -j DROP&lt;br /&gt;
 &lt;br /&gt;
 /sbin/iptables-save &amp;gt; /etc/sysconfig/iptables&lt;br /&gt;
 /sbin/service iptables restart&lt;br /&gt;
&lt;br /&gt;
We still have to create the client certificate and configure the client to connect to our OpenVPN Service.&lt;/div&gt;</summary>
		<author><name>Didier</name></author>
	</entry>
</feed>