- Lab
-
Libraries: If you want this lab, consider one of these libraries.
- Cloud
- Security
Working with OpenVPN (and iptables)
Understanding Virtual Private Networks (VPsN) is essential for many advanced level certification tests. OpenVPN is a popular VPN solution that enjoys somewhat common use. This exercise focuses on configuring a basic VPN server and client.
Lab Info
Table of Contents
-
Challenge
Install and configure the OpenVPN server on `vpn-server`.
Install OpenVPN:
-
Run
yum install -y openvpn. -
Copy the server config:
cp /usr/share/doc/openvpn-2.4.7/sample/sample-config-files/server.conf /etc/openvpn/ -
Edit the server config to contain the following topology configuration:
topology subnet
-
-
Challenge
Install the provided server certificates.
Run:
cp /home/cloud_user/certs/ca.crt /home/cloud_user/certs/server.crt /home/cloud_user/certs/server.key /etc/openvpn -
Challenge
Generate the required server keys.
- Generate the
dhparamkey (this may take a few minutes):
openssl dhparam -out /etc/openvpn/dh2048.pem 2048- Generate the key for
tls-authand copy it toclient:
openvpn --genkey --secret /etc/openvpn/ta.keyscp /etc/openvpn/ta.key cloud_user:/home/cloud_user/ta.key - Generate the
-
Challenge
Make the necessary firewall and routing configurations for OpenVPN on `vpn-server`.
Run the following commands:
iptables -I INPUT -p udp --dport 1194 -j ACCEPTiptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADEiptables-save > /etc/sysconfig/iptablessysctl -w net.ipv4.ip_forward=1 -
Challenge
Enable and start the OpenVPN server.
Run the following:
systemctl enable openvpn@serversystemctl start openvpn@server -
Challenge
Install and configure the OpenVPN client on `vpn-client`.
On
vpn-client, perform the following steps:- Install OpenVPN:
yum install y openvpn- Copy the
client.conffile from/usr/share/doc:
cp /usr/share/doc/openvpn-2.4.7/sample/sample-config-files/client.conf /etc/openvpn/- Update the
remotecommand hostname directive in/etc/openvpn/client.confas follows:
remote vpn-server 1194 -
Challenge
Install the provided client and ca-certificates on `vpn-client`.
Copy the provided certificates off of
vpn-serverand to the noted directories onvpn-clientwith the following commands.Run on the host
vpn-client:cp /home/cloud_user/ca.crt /etc/openvpn/cp /home/cloud_user/client.key /etc/openvpn/cp /home/cloud_user/client.crt /etc/openvpn/ -
Challenge
Install the `tls` key from `vpn-server` on `vpn-client`.
Assuming you copied the
tlskey over to/home/cloud_user/ta.keywhen you created it in the earlier tasks, runcp /home/cloud_user/ta.key /etc/openvpn/ta.key.If not, you will need to retrieve the file from
vpn-server:/etc/openvpn/ta.key. -
Challenge
Enable and start the OpenVPN client.
Run the following commands:
systemctl enable openvpn@clientsystemctl start openvpn@client
About the author
Real skill practice before real-world application
Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.
Learn by doing
Engage hands-on with the tools and technologies you’re learning. You pick the skill, we provide the credentials and environment.
Follow your guide
All labs have detailed instructions and objectives, guiding you through the learning process and ensuring you understand every step.
Turn time into mastery
On average, you retain 75% more of your learning if you take time to practice. Hands-on labs set you up for success to make those skills stick.