Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Create a VPN on EC2 in 30 seconds
# linux firewall/forwarding
modprobe iptable_nat
echo 1 | tee /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s -o eth0 -j MASQUERADE
# install openvpn
apt-get update && apt-get install -y openvpn
cd /etc/openvpn/
openvpn --genkey --secret ${INSTANCE}.key
cat > openvpn.conf <<OPENVPN
dev tun1
port 443
proto tcp-server
secret ${INSTANCE}.key
service openvpn restart
# create a (for use with tunnelblick or any openvpn clients)
cd /etc/openvpn/
cat > ${INSTANCE}.conf <<OPENVPN
dev tun
dhcp-option DNS
port 443
proto tcp-client
redirect-gateway def1
remote ${INSTANCE}
secret ${INSTANCE}.key
apt-get install -y zip
zip ${INSTANCE}.conf ${INSTANCE}.key
# scp /etc/openvpn/ to your machine for use
# imports straight into tunnelblick on a mac
Copy link

lucaspiller commented Aug 28, 2013

The URL used for the INSTANCE variable doesn't work for me, but I'm assuming it returns the same as

Copy link

rayrod2030 commented Aug 29, 2013

@lucaspiller That URL only works from within EC2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment