Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
howtos:network_services:openvpn [2014/01/04 20:28 (UTC)]
chrisabela
howtos:network_services:openvpn [2018/03/02 00:28 (UTC)]
bifferos Move passphrase removal to the passphrase section
Line 54: Line 54:
 ==== 4.3 Administrator Rights ==== ==== 4.3 Administrator Rights ====
  
-You will need to have administrator rights to set up the Openvpn. This applies to both the Server and the Client. For simplicity, in this tutorial, it will be assumed that all actions will be performed by the root user. Naturally advanced users might be more discerning.+You will need to have administrator rights to set up OpenVPN. This applies to both the Server and the Client. For simplicity, in this tutorial, it will be assumed that all actions will be performed by the root user. Naturally advanced users might be more discerning.
  
 ==== 4.4 Possible Constraints and Possible Solutions for a WiFi equipped Client ==== ==== 4.4 Possible Constraints and Possible Solutions for a WiFi equipped Client ====
Line 70: Line 70:
 <​code>​ <​code>​
 # cd # cd
-# git clone git://​github.com/​OpenVPN/​easy-rsa+# git clone http://​github.com/​OpenVPN/​easy-rsa
 </​code>​ </​code>​
  
Line 144: Line 144:
 === 5.2.1 Sign the Client'​s request on the Server === === 5.2.1 Sign the Client'​s request on the Server ===
  
-For the purpose of this article, it is assumed that the Client'​s request file (client1.req) been transferred to the $HOME/​openvpn/​ directory of the Server. Now you can proceed to import and sign the client1 request:+For the purpose of this article, it is assumed that the Client'​s request file (client1.req) ​has been transferred to the $HOME/​openvpn/​ directory of the Server. Now you can proceed to import and sign the client1 request:
  
 <​code>​ <​code>​
Line 170: Line 170:
 </​code>​ </​code>​
  
-Copy the sample server.conf from the openvpn ​source onto the openvpn's configuration directory. The source of openvpn ​may be obtained from Slackware'​s source DVD or your favourite Slackware mirror or from http://​openvpn.net. In the following example I am downloading the source from ftp.slackware.com+Copy the sample server.conf from the OpenVPN ​source onto the OpenVPN's configuration directory. The source of OpenVPN ​may be obtained from Slackware'​s source DVD or your favourite Slackware mirror or from http://​openvpn.net. In the following example I am downloading the source from ftp.slackware.com
  
 <​code>​ <​code>​
Line 180: Line 180:
 </​code>​ </​code>​
  
-Copy the file server.conf contained in the source to the openvpn ​configuration directory:+Copy the file server.conf contained in the source to the OpenVPN ​configuration directory:
  
 <​code>​ <​code>​
-# cp openvpn-2.3.2/​sample/​sample-config-files/​server.conf \+# cp openvpn-*/​sample/​sample-config-files/​server.conf \
 > /​etc/​openvpn/​ > /​etc/​openvpn/​
 </​code>​ </​code>​
Line 230: Line 230:
 daemon daemon
 </​code>​ </​code>​
 +
 +<​note>​It may be useful to leave off the '​daemon'​ option while getting things up and running so you can see useful messages in the foreground.</​note>​
  
 My full server.conf is the following: My full server.conf is the following:
Line 548: Line 550:
 # /​etc/​rc.d/​rc.openvpn ​ # /​etc/​rc.d/​rc.openvpn ​
  
-# Start/​stop/​restart the openvpn ​server. ​+# Start/​stop/​restart the OpenVPN ​server. ​
 # #
    
Line 589: Line 591:
 </​code>​ </​code>​
  
-Eventually when you start openvpn ​on the server, you may read /​var/​log/​openvpn.log to verify that your work has been successful:+Eventually when you start OpenVPN ​on the server, you may read /​var/​log/​openvpn.log to verify that your work has been successful:
  
 <​code>​ <​code>​
Line 597: Line 599:
 ===== 7. Port Forwarding ===== ===== 7. Port Forwarding =====
  
-YYou will need to forward traffic from the port you have chosen for Openvpn ​to be routed to the Server. To accomplish this you will need to provide your Server with a fixed IP and you will need to configure your router. You may use netconfig, wicd or network-manager to set the fixed IP on Slackware. Then you also need to consult the documentation provided with your router to set up the selected IP address reserved for the Server, and the port forwarding. For our default ​Openvpn ​set up, the UDP Port would be 1194. +You will need to forward traffic from the port you have chosen for OpenVPN ​to be routed to the Server. To accomplish this you will need to provide your Server with a fixed IP and you will need to configure your router. You may use netconfig, wicd or network-manager to set the fixed IP on Slackware. Then you also need to consult the documentation provided with your router to set up the selected IP address reserved for the Server, and the port forwarding. For our default ​OpenVPN ​set up, the UDP Port would be 1194. 
  
 In case if you have misplaced such documentation,​ you may search on the Internet on how this may be achieved. A good place to start is http://​portforward.com/​. In case if you have misplaced such documentation,​ you may search on the Internet on how this may be achieved. A good place to start is http://​portforward.com/​.
Line 605: Line 607:
 On the Client machine perform the following instructions to set it up. On the Client machine perform the following instructions to set it up.
  
-Download the openvpn ​source tarball and extracted it as explained in Chapter 6, then proceed to copy the included configuration file for clients:+Download the OpenVPN ​source tarball and extracted it as explained in Chapter 6, then proceed to copy the included configuration file for clients:
  
 <​code>​ <​code>​
Line 644: Line 646:
 <​note>​Note that comments in client.conf may be either # or ; The former are used to comment out text while the latter are for commented out configuration lines. This should help you a lot in the configuration process.</​note>​ <​note>​Note that comments in client.conf may be either # or ; The former are used to comment out text while the latter are for commented out configuration lines. This should help you a lot in the configuration process.</​note>​
  
-You will need the this files that were generated by the Client'​s easy-rsa scripts:+You will need this file that were generated by the Client'​s easy-rsa scripts:
  
 <​code>​ <​code>​
Line 818: Line 820:
 </​code>​ </​code>​
  
-Enter the Client PEM pass phrase when prompted. To stop openVPN ​on the Client just hit CTRL+C+Enter the Client PEM pass phrase when prompted. To stop OpenVPN ​on the Client just hit CTRL+C
  
 On both you should see a new network interface called tun0. On the Server, I obtained the following: On both you should see a new network interface called tun0. On the Server, I obtained the following:
Line 864: Line 866:
 ===== 10. Storing the PEM pass phrase in a secure file and Automatic start of service after booting ===== ===== 10. Storing the PEM pass phrase in a secure file and Automatic start of service after booting =====
  
-To start the Openvpn ​service on boot, an entry in /​etc/​rc.d/​rc.local is needed, but you would have to enter the server PEM pass phrase every time. This might be undesirable if the Server is unreachable. If this is the case, create a file containing your PEM pass phrase in a secure location; e.g. /​root/​password.ovpn which contains only this pass phrase. Then restrict its permission:+To start the OpenVPN ​service on boot, an entry in /​etc/​rc.d/​rc.local is needed, but you would have to enter the server PEM pass phrase every time. This might be undesirable if the Server is unreachable. If this is the case, create a file containing your PEM pass phrase in a secure location; e.g. /​root/​password.ovpn which contains only this pass phrase. Then restrict its permission:
  
 <​code>​ <​code>​
Line 879: Line 881:
 This may be repeated also on the Client, just edit /​etc/​openvpn/​client.conf instead of /​etc/​openvpn/​server.conf. This may be repeated also on the Client, just edit /​etc/​openvpn/​client.conf instead of /​etc/​openvpn/​server.conf.
  
-To start the Openvpn ​service automatically on boot-up from the Server, include these lines in /​etc/​rc.d/​rc.local+To start the OpenVPN ​service automatically on boot-up from the Server, include these lines in /​etc/​rc.d/​rc.local
  
 <​code>​ <​code>​
Line 887: Line 889:
 fi fi
 </​code>​ </​code>​
 +
 +An alternate method (albeit less secure) is to remove the passphrase from server1.key file altogether. ​ Don't forget to set permissions on the key to avoid it being world-readable.
 +
 +<​code>​
 +# cd /​etc/​openvpn/​keys
 +# openssl rsa -in server1.key -out tmp.key
 +# mv tmp.key server1.key
 +# chmod 600 server1.key
 +</​code>​
 +
  
 ===== 11. IP Routing ===== ===== 11. IP Routing =====
Line 922: Line 934:
 push "route 192.168.200.0 255.255.255.0"​ push "route 192.168.200.0 255.255.255.0"​
  
-client-config-dir ccd +client-config-dir ​/​etc/​openvpn/​ccd 
 route 192.168.1.0 255.255.255.0 ​ route 192.168.1.0 255.255.255.0 ​
  
Line 1002: Line 1014:
   $IPT -A INPUT -j SERVICES # append the services chain to the input    $IPT -A INPUT -j SERVICES # append the services chain to the input 
  
-  # allowed forwarding for openVPN+  # allowed forwarding for OpenVPN
   $IPT -A FORWARD -i eth0 -o tun0 -m state --state ESTABLISHED,​RELATED -j ACCEPT   $IPT -A FORWARD -i eth0 -o tun0 -m state --state ESTABLISHED,​RELATED -j ACCEPT
   $IPT -A FORWARD -s 10.8.0.0/24 -o eth0 -j ACCEPT   $IPT -A FORWARD -s 10.8.0.0/24 -o eth0 -j ACCEPT
  
-  # masquerade the openvpn ​network+  # masquerade the OpenVPN ​network
   $IPT -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE   $IPT -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
  
Line 1012: Line 1024:
   #$IPT -A SERVICES -p tcp --dport 22 -j ACCEPT # Uncomment to allow sshd   #$IPT -A SERVICES -p tcp --dport 22 -j ACCEPT # Uncomment to allow sshd
  
-  # allow openvpn ​for the non-default ​tcp port 443 +  # allow OpenVPN ​for the default ​udp port 1194 
-  $IPT -A SERVICES -p tcp --dport ​443 -j ACCEPT+  $IPT -A SERVICES -p udp --dport ​1194 -j ACCEPT
   ​   ​
   echo "​done."​   echo "​done."​
Line 1069: Line 1081:
 </​code>​ </​code>​
  
-Restart the Openvpn ​service on the Server:+Restart the OpenVPN ​service on the Server:
  
 <​code>​ <​code>​
Line 1083: Line 1095:
 ===== 12. Firewalls ===== ===== 12. Firewalls =====
  
-In the previous chapter we referred to a firewall you may include to protect your Openvpn ​Server. ​ However this chapter refers to firewalls on the Client LAN that may block the VPN connection by blocking traffic on UDP port 1194.+In the previous chapter we referred to a firewall you may include to protect your OpenVPN ​Server. ​ However this chapter refers to firewalls on the Client LAN that may block the VPN connection by blocking traffic on UDP port 1194.
  
 In order to penetrate through the Client firewall your may want to try changing the port to 443 - normally reserved for https. Using TCP instead of UDP will also help. To make these change you will need to amend /​etc/​openvpn/​server.conf of the Server, from In order to penetrate through the Client firewall your may want to try changing the port to 443 - normally reserved for https. Using TCP instead of UDP will also help. To make these change you will need to amend /​etc/​openvpn/​server.conf of the Server, from

In Other Languages
QR Code
QR Code howtos:network_services:openvpn (generated for current page)