* install EPEL yum install epel-release * install OpenVPN and EPEL yum install openvpn easy-rsa -y * make config file for openvpn cp /usr/share/doc/openvpn-*/sample/sample-config-files/server.conf /etc/openvpn vim /etc/openvpn/server.conf * Change config file. Set the DH file name and uncomment following dh file name to dh2048.pem push "redirect-gateway def1 bypass-dhcp" #replace with VPN DNS??? push "dhcp-option DNS 8.8.8.8" push "dhcp-option DNS 8.8.4.4" #user unprivileged user user nobody group nobody * Generate keys and certificates mkdir -p /etc/openvpn/easy-rsa/keys cp -rf /usr/share/easy-rsa/2.0/* /etc/openvpn/easy-rsa Now, we’re going to edit the default values in the script. So we don’t have to type our information in each time. Open the file in vi editor. vim /etc/openvpn/easy-rsa/vars Change values that start with KEY_. Update the following values to be accurate for your organization. Some of the important value that should be change carefully are, KEY_NAME: You should enter server here; you could enter something else, but then you would also have to update the configuration files that reference and KEY_CN: Enter the domain or subdomain that resolves to your server sample file below . . . # These are the default values for fields # which will be placed in the certificate. # Don't leave any of these fields blank. export KEY_COUNTRY="NL" export KEY_PROVINCE="ZH" export KEY_CITY="Den Haag" export KEY_ORG="test" export KEY_EMAIL="test@test.test" export KEY_OU="Community" # X509 Subject Field export KEY_NAME="server" . . . export KEY_CN=vpn.test.com . . . * note: OpenSSL configuration may not load due to the version being undetectable. To avoid this remove the version number from the openSSl file name. cp /etc/openvpn/easy-rsa/openssl-1.0.0.cnf /etc/openvpn/easy-rsa/openssl.cnf * Next, We are going to generate the keys and certificates. Move to easy-rsa directory and source in our new variables. cd /etc/openvpn/easy-rsa source ./vars Then, we will clean up any keys and certificates which may already be in this folder and generate our certificate authority. ./clean-all When you build the certificate authority, you will be asked to enter all the information we put into the vars file, but you will see that your options are already set as the defaults. So, you can just press ENTER for each one. ./build-ca Next, We will generate the key and certificate for the server. Please press ENTER for each question as for the above step ./build-key-server server Now we will generate Diffie-Hellman key exchange file. This command will take few to complete: ./build-dh So, we completed the server keys and certificates generation process. Copy them all into our OpenVPN directory. cd /etc/openvpn/easy-rsa/keys cp dh2048.pem ca.crt server.crt server.key /etc/openvpn For authenticate our clients will also need certificates. These keys and certificates will be shared with your clients, and it’s best to generate separate keys and certificates for each client you intend on connecting. Make sure that if you do this you give them descriptive names, but for now we’re going to have one client so we’ll just call it client. cd /etc/openvpn/easy-rsa ./build-key client That's it for keys and certificates. * change the firewall settings Use the firewall-cmd command. Assuming you're opening the firewall up to OpenVPN on the default zone, carry out the following commands. If you are running it on a non-default zone, then add --zone= to the commands. First, list what's currently open: # firewall-cmd --list-services http https ssh Next, add the openvpn service: # firewall-cmd --add-service openvpn success A quick check: # firewall-cmd --list-services http https openvpn ssh The above will allow openvpn to work, which you can now test. However, it won't last over restarts. To make it permanent, add the --permanent option: # firewall-cmd --permanent --add-service openvpn success Finally, add the masquerade: # firewall-cmd --add-masquerade success And make it permanent after a restart: # firewall-cmd --permanent --add-masquerade success Confirm it: # firewall-cmd --query-masquerade yes // Note that if your incoming OpenVPN connection is in a different zone to your Internet facing connection the masquerade should be on the latter and you'll need to use the --zone= option with the --add-masquerade commands. //