<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: How do you setup OpenVPN  with FreeBSD + PF and Windows?</title>
	<atom:link href="http://hosting-provider-web.com/web-hosting-solutions/windows-hosting/windows-vps-hosting/how-do-you-setup-openvpn-with-freebsd-pf-and-windows/feed" rel="self" type="application/rss+xml" />
	<link>http://hosting-provider-web.com/web-hosting-solutions/windows-hosting/windows-vps-hosting/how-do-you-setup-openvpn-with-freebsd-pf-and-windows</link>
	<description>Reviews on  Web Hosting .</description>
	<lastBuildDate>Mon, 09 Aug 2010 19:23:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: markobaja01</title>
		<link>http://hosting-provider-web.com/web-hosting-solutions/windows-hosting/windows-vps-hosting/how-do-you-setup-openvpn-with-freebsd-pf-and-windows/comment-page-1#comment-667</link>
		<dc:creator>markobaja01</dc:creator>
		<pubDate>Sat, 16 Jan 2010 16:25:59 +0000</pubDate>
		<guid isPermaLink="false">http://hosting-provider-web.com/windows-vps-hosting/how-do-you-setup-openvpn-with-freebsd-pf-and-windows#comment-667</guid>
		<description>OpenVPN with FreeBSD, PF and Windows

This howto is a quick a dirty guide to building OpenVPN on a FreeBSD box (running pf as the firewall), and then connecting a Windows XP client to it. Server Install
[edit] Install the port

cd /usr/ports/security/openvpn
make install

[edit] Start setting stuff up

First edit your /etc/rc.conf and add the following line:-

openvpn_enable=”YES”

Now create the config files, which we will place in /usr/local/etc/openvpn:-

cd /usr/local/etc/
mkdir openvpn
cd openvpn

vim openvpn.conf

Place this into your config file:-

# Specify device
dev tun

# Server and client IP and Pool
server 10.8.0.0 255.255.255.0
ifconfig-pool-persist ipp.txt

# Certificates for VPN Authentication
ca /usr/local/etc/openvpn/keys/ca.crt
cert /usr/local/etc/openvpn/keys/server.crt
key /usr/local/etc/openvpn/keys/server.key
dh /usr/local/etc/openvpn/keys/dh1024.pem

# Routes to push to the client
push &quot;route 192.168.0.0 255.255.255.0&quot;

# Use compression on the VPN link
comp-lzo

# Make the link more resistant to connection failures

keepalive 10 60
ping-timer-rem
persist-tun
persist-key

# Run OpenVPN as a daemon and drop privileges to user/group nobody user nobody
group nobody
daemon

[edit] Creating Certificates

cp -r /usr/local/share/doc/openvpn/easy-rsa /home/myuser/ cd /home/myuser/easy-rsa

Now edit the “vars” file to set your specific details and set the environment variables you have just created and build the Certificate Authority certificates:-

NOTE: Very Important Step for FreeBSD/TCSH users

FreeBSD ships with tcsh as its native shell, at the time of writing the following scripts do not work. To get around this you must drop down to a bourne shell. To do this just type the following at a prompt:-

sh

Now you can carry on with building the certificates, once you have built them you can exit back out to tcsh.

. vars
./clean-all
./build-ca

You will have to answer a few questions on the last step, once this has been done your CA certs will be created in the keys subdirectory.

Generate certificate &amp; key for server:-

./build-key-server server

Again answer the questions and the certs will be placed in the keys subdirectory.

Generate certificates &amp; keys for 3 clients (each client will require their own certificates, if multiple clients log in with the same certs then they will be assigned the same ips and will kick each other off the network):-

Generating client certificates is very similar to the previous step. You need to ensure that all your details are the same as for the CA, apart from the common name, which needs to be different for each client. For the sake of clarity this should relate to person who is assigned this vpn certificate. All of these details can be found in keys/server.crt for the server and keys/client*.crt for the client details.

./build-key client1
./build-key client2
./build-key client3

Generate Diffie Hellman parameters

Diffie Hellman parameters must be generated for the OpenVPN server:-

./build-dh

Now copy the whole keys directory to /usr/local/etc/openvpn:-

cp -r keys /usr/local/etc/openvpn/


[edit] Logging

Before starting OpenVPN I also moved the logging (which defaults to /var/log/messages). Edit syslog.conf:-

vim /etc/syslog.conf

Add the following entry:-

!openvpn
*.* /var/log/openvpn.log

Create log file:-

touch /var/log/openvpn.log

Restart syslogd:-

killall -HUP syslogd

Now start OpenVPN:-

/usr/local/etc/rc.d/openvpn.sh start

Check /var/log/openvpn.log for errors, then check that the device has been created. Mine looks like this:-

[achilles] ~# ifconfig tun0
tun0: flags=8051&lt;UP,POINTOPOINT,RUNNING,MULTICAST&gt; mtu 1500
inet6 fe80::2d0:b7ff:fe49:b2bb%tun0 prefixlen 64 scopeid 0x5
inet 10.8.0.1 --&gt; 10.8.0.2 netmask 0xffffffff
Opened by PID 43878

[edit] Firewall Configuration

Now we need to alter PF to handle the VPN, below are the relevant sections of my /etc/pf.conf file:-

# VPN Interface
vpn_if=&quot;tun0&quot;

# VPN Network
vpn_network=&quot;10.8.0.0/24&quot;

# NAT the VPN connections (for access to the remote secure networks)
nat on $ext_if from $vpn_network to any -&gt; ($ext_if)

# VPN connections inbound
pass in on $ext_if proto udp from any to port 1194 keep state
pass quick on $vpn_if

Now restart PF and your server will be ready for connections
[edit] Client setup

First download and install the GUI version of the client, which can be found here:-

http://www.openvpn.se

Once this is installed you will need to copy the following files from your server /usr/local/etc/openvpn/keys directory to the Windows PC C:\Program Files\Openvpn\config directory (this should be done in as secure a manner as possible, i.e. USB Stick or floppy rather than email!!!):-

ca.crt
client1.crt
client1.key

NOTE: For the next client you will need to copy the client2.crt and client2.key files to prevent issues later.&lt;br&gt;&lt;b&gt;References : &lt;/b&gt;&lt;br&gt;http://www.stardothosting.com/linux-vps-hosting</description>
		<content:encoded><![CDATA[<p>OpenVPN with FreeBSD, PF and Windows</p>
<p>This howto is a quick a dirty guide to building OpenVPN on a FreeBSD box (running pf as the firewall), and then connecting a Windows XP client to it. Server Install<br />
[edit] Install the port</p>
<p>cd /usr/ports/security/openvpn<br />
make install</p>
<p>[edit] Start setting stuff up</p>
<p>First edit your /etc/rc.conf and add the following line:-</p>
<p>openvpn_enable=”YES”</p>
<p>Now create the config files, which we will place in /usr/local/etc/openvpn:-</p>
<p>cd /usr/local/etc/<br />
mkdir openvpn<br />
cd openvpn</p>
<p>vim openvpn.conf</p>
<p>Place this into your config file:-</p>
<p># Specify device<br />
dev tun</p>
<p># Server and client IP and Pool<br />
server 10.8.0.0 255.255.255.0<br />
ifconfig-pool-persist ipp.txt</p>
<p># Certificates for VPN Authentication<br />
ca /usr/local/etc/openvpn/keys/ca.crt<br />
cert /usr/local/etc/openvpn/keys/server.crt<br />
key /usr/local/etc/openvpn/keys/server.key<br />
dh /usr/local/etc/openvpn/keys/dh1024.pem</p>
<p># Routes to push to the client<br />
push &quot;route 192.168.0.0 255.255.255.0&quot;</p>
<p># Use compression on the VPN link<br />
comp-lzo</p>
<p># Make the link more resistant to connection failures</p>
<p>keepalive 10 60<br />
ping-timer-rem<br />
persist-tun<br />
persist-key</p>
<p># Run OpenVPN as a daemon and drop privileges to user/group nobody user nobody<br />
group nobody<br />
daemon</p>
<p>[edit] Creating Certificates</p>
<p>cp -r /usr/local/share/doc/openvpn/easy-rsa /home/myuser/ cd /home/myuser/easy-rsa</p>
<p>Now edit the “vars” file to set your specific details and set the environment variables you have just created and build the Certificate Authority certificates:-</p>
<p>NOTE: Very Important Step for FreeBSD/TCSH users</p>
<p>FreeBSD ships with tcsh as its native shell, at the time of writing the following scripts do not work. To get around this you must drop down to a bourne shell. To do this just type the following at a prompt:-</p>
<p>sh</p>
<p>Now you can carry on with building the certificates, once you have built them you can exit back out to tcsh.</p>
<p>. vars<br />
./clean-all<br />
./build-ca</p>
<p>You will have to answer a few questions on the last step, once this has been done your CA certs will be created in the keys subdirectory.</p>
<p>Generate certificate &amp; key for server:-</p>
<p>./build-key-server server</p>
<p>Again answer the questions and the certs will be placed in the keys subdirectory.</p>
<p>Generate certificates &amp; keys for 3 clients (each client will require their own certificates, if multiple clients log in with the same certs then they will be assigned the same ips and will kick each other off the network):-</p>
<p>Generating client certificates is very similar to the previous step. You need to ensure that all your details are the same as for the CA, apart from the common name, which needs to be different for each client. For the sake of clarity this should relate to person who is assigned this vpn certificate. All of these details can be found in keys/server.crt for the server and keys/client*.crt for the client details.</p>
<p>./build-key client1<br />
./build-key client2<br />
./build-key client3</p>
<p>Generate Diffie Hellman parameters</p>
<p>Diffie Hellman parameters must be generated for the OpenVPN server:-</p>
<p>./build-dh</p>
<p>Now copy the whole keys directory to /usr/local/etc/openvpn:-</p>
<p>cp -r keys /usr/local/etc/openvpn/</p>
<p>[edit] Logging</p>
<p>Before starting OpenVPN I also moved the logging (which defaults to /var/log/messages). Edit syslog.conf:-</p>
<p>vim /etc/syslog.conf</p>
<p>Add the following entry:-</p>
<p>!openvpn<br />
*.* /var/log/openvpn.log</p>
<p>Create log file:-</p>
<p>touch /var/log/openvpn.log</p>
<p>Restart syslogd:-</p>
<p>killall -HUP syslogd</p>
<p>Now start OpenVPN:-</p>
<p>/usr/local/etc/rc.d/openvpn.sh start</p>
<p>Check /var/log/openvpn.log for errors, then check that the device has been created. Mine looks like this:-</p>
<p>[achilles] ~# ifconfig tun0<br />
tun0: flags=8051&lt;UP,POINTOPOINT,RUNNING,MULTICAST&gt; mtu 1500<br />
inet6 fe80::2d0:b7ff:fe49:b2bb%tun0 prefixlen 64 scopeid 0&#215;5<br />
inet 10.8.0.1 &#8211;&gt; 10.8.0.2 netmask 0xffffffff<br />
Opened by PID 43878</p>
<p>[edit] Firewall Configuration</p>
<p>Now we need to alter PF to handle the VPN, below are the relevant sections of my /etc/pf.conf file:-</p>
<p># VPN Interface<br />
vpn_if=&quot;tun0&quot;</p>
<p># VPN Network<br />
vpn_network=&quot;10.8.0.0/24&quot;</p>
<p># NAT the VPN connections (for access to the remote secure networks)<br />
nat on $ext_if from $vpn_network to any -&gt; ($ext_if)</p>
<p># VPN connections inbound<br />
pass in on $ext_if proto udp from any to port 1194 keep state<br />
pass quick on $vpn_if</p>
<p>Now restart PF and your server will be ready for connections<br />
[edit] Client setup</p>
<p>First download and install the GUI version of the client, which can be found here:-</p>
<p><a href="http://www.openvpn.se" rel="nofollow">http://www.openvpn.se</a></p>
<p>Once this is installed you will need to copy the following files from your server /usr/local/etc/openvpn/keys directory to the Windows PC C:\Program Files\Openvpn\config directory (this should be done in as secure a manner as possible, i.e. USB Stick or floppy rather than email!!!):-</p>
<p>ca.crt<br />
client1.crt<br />
client1.key</p>
<p>NOTE: For the next client you will need to copy the client2.crt and client2.key files to prevent issues later.<br /><b>References : </b><br /><a href="http://www.stardothosting.com/linux-vps-hosting" rel="nofollow">http://www.stardothosting.com/linux-vps-hosting</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
