I'm assuming you have OpenBSD installed, if not RTFM (or FAQ in this case) and then come back. Install your package via your preferred method (pkg_add, build from ports, compile, magic).
After installation you should have a some new directories in /etc/openvpn/ or if you decided you wanted to put them somewhere else, in your wierd spot.
Run the following commands to set up your certificates and keys for servers and clients:
# mkdir -p /etc/openvpn/keys
# cp -r /usr/local/share/examples/openvpn/easy-rsa /etc/openvpn
# chown -R root:wheel /etc/openvpn
# chmod 700 /etc/openvpn/keys
# cd /etc/openvpn/easy-rsa
# . ./vars
# ./clean-all
# ./build-ca
# ./build-key-server server
# ./build-key client1
# ./build-key client2 etc.
# ./build-dh
# /usr/local/sbin/openvpn --genkey --secret ta.key
# cd keys
# mv ca.crt dh1024.pem server.crt server.key ta.key /etc/openvpn/keys
# chmod 644 /etc/openvpn/keys/{ca.crt,dh1024.pem,server.crt}
# chmod 600 /etc/openvpn/keys/{server.key,ta.key}
This sets up keys for both our ssl verification (ca.crt, server.crt, server.key) and the TLS authentication (ta.key).
On to the server configuration.
daemon openvpnIssue the following commands at your command line to create the logfile and tunnel device, user and group, and start the server:
/var/run/openvpn.pid
/var/log/openvpn.log
local 10.0.0.1 # change to your external IP
port 1194
proto udp
dev tun0
dev-type tap
client-to-client
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/terminus.crt
key /etc/openvpn/keys/terminus.key
dh /etc/openvpn/keys/dh1024.pem
server 192.168.5.0 255.255.255.0
ifconfig-pool-persist /var/openvpn/ipp.txt
push "route 172.16.0.0 255.255.0.0"
push "dhcp-option DNS 172.16.0.1"
push "dhcp-option DNS 172.15.0.2"
keepalive 10 120
tls-auth /etc/openvpn/keys/ta.key 0
cipher BF-CBC
max-clients 20
user _openvpn
group _openvpn
persist-key
persist-tun
verb 3
mute 20
chroot /var/empty
# touch /var/log/openvpn.log
# cd /dev/
# ./MAKEDEV tun0# groupadd -g 500 _openvpn
# useradd -u 500 -g 500 -c 'OpenVPN Server' -s /sbin/nologin -d /var/openvpn -m _openvpn
# /usr/local/sbin/openvpn --config /etc/openvpn/server.conf
Next we edit your pf.conf to allow incoming and outgoing traffic on UDP port 1194
pass in quick on $ext_if proto udp from any to $ext_ip port 1194 keep state
pass out quick on $ext_if proto udp from any to $ext_ip port 1194 keep state
Edit your /etc/rc.local and add a couple lines to start OpenVPN at startup:
if [ -x /usr/local/sbin/openvpn ]; thenNow time to install the client on your Windows boxes. We'll be leaning on the hard work of Mathias Sundman who made an OpenVPN GUI for Windows. Go to this link and follow the directions for downloading the package as well as the program to build your own OpenVPN Client install. I used the 2.0.9 source package since it seemed to work in both XP and Vista.
echo -n " Starting OpenVPN..."; /usr/local/sbin/openvpn --config /etc/openvpn/server.conf
fi
Using the most secure method, every client will need there own certificate/key pair copied to the client for connecting. Since most of my users are already logging into the domain to access the computer, I wanted to make the setup as simple as possible so I made one cert/key pair and copied the same one to every client in my install. If you'd prefer to keep track of the clients better, forgo the next part about editing NSIS setup script to copy the keys automagically.
First copy this config file into ~\openvpn_install_source-2.0.9-gui-1.0.3\openvpn\config\ovpn.config
clientAlso copy the following to the config directory. Remember, if you'd like every client to have a different cert/key pair, then you'd remove the client1.cert and client1.key and copy them over manually after you've installed the GUI.
dev tap
proto udp
remote 192.168.5.0 1194 # replace with your access point's IP
resolv-retry infinite
nobind
ca ca.crt
cert client1.crt
key client1.key
ns-cert-type server
tls-auth ta.key 1
route-method exe
route-delay 2
ping 10
verb 3
mute 10
ca.crt
client1.key
client1.crt
ta.key
Next edit the openvpn-gui.nsi script and scroll down to the section containing:
# Include your custom config file(s) here.
SetOutPath "$INSTDIR\config"
Add the following, changing the names of the certs/keys to your corresponding pair. Leave out the client.crt/key if using seperate keys for every client:
File "${HOME}\config\config.ovpn"
File "${HOME}\config\ca.crt"
File "${HOME}\config\client1.crt"
File "${HOME}\config\client1.key"
File "${HOME}\config\ta.key"
In the ~\openvpn_install_source-2.0.9-gui-1.0.3\ directory right click on the openvpn-gui.nsi script and compile it. You should now have an .exe to install the client onto Windows.
Go ahead and test out the install, you should have a working VPN at this point. Since I decided to use the same client key/cert for every user, I had to add an extra option when starting OpenVPN which lets multiple clients connect with the same cert/key:
/usr/local/sbin/openvpn --config /etc/openvpn/server.conf --duplicate-cn
If you did as well remember to edit your startup script to use the same option, or people will end up all fighting over the same connection.
One thing I should also mention is proxy arp'ing. As of the current post I had to add a static route on my inside servers to show it where the return VPN subnet traffic was supposed to go (the inside lan address of your VPN server). I know for Poptop I used a proxy arp script to make my VPN subnet public to the rest of the LAN, would the same work for OpenVPN? I've tried it using the same script, and it appears not. Suggestions?
No comments:
Post a Comment