Skip to content

Instantly share code, notes, and snippets.

@ccamacho
Created August 14, 2016 20:35
Show Gist options
  • Select an option

  • Save ccamacho/a8c0ffd5050fee03df6b45188863c4be to your computer and use it in GitHub Desktop.

Select an option

Save ccamacho/a8c0ffd5050fee03df6b45188863c4be to your computer and use it in GitHub Desktop.
cd
sudo apt-get update
sudo apt-get install openvpn easy-rsa
sudo touch /etc/openvpn/server.conf
sudo gunzip -c /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz > server.conf
sudo mv server.conf /etc/openvpn/
Change "dh dh1024.pem" to "dh dh2048.pem"
Uncomment:
push "redirect-gateway def1 bypass-dhcp"
push "dhcp-option DNS 208.67.222.222"
push "dhcp-option DNS 208.67.220.220"
user nobody
group nogroup
Enable: package forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
Edit and uncomment: /etc/sysctl.conf
#net.ipv4.ip_forward=1
Now Uncomplicated Firewall (ufw)..
sudo ufw allow ssh
sudo ufw allow 1194/udp
Update /etc/default/ufw
DEFAULT_FORWARD_POLICY="ACCEPT"
Add to the begining of to: /etc/ufw/before.rules
# START OPENVPN RULES
# NAT table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Allow traffic from OpenVPN client to eth0
-A POSTROUTING -s 10.8.0.0/8 -o eth0 -j MASQUERADE
COMMIT
# END OPENVPN RULES
ufw enable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment