<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Computer Solutions Blog &#187; openvpn</title>
	<atom:link href="http://www.computersolutions.cn/blog/tag/openvpn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.computersolutions.cn/blog</link>
	<description>Whats happening at Computer Solutions</description>
	<lastBuildDate>Fri, 13 Jan 2012 02:32:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>OpenVPN setup notes (with dnscache goodness)</title>
		<link>http://www.computersolutions.cn/blog/2009/11/openvpn-setup-notes-with-dnscache-goodness/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=openvpn-setup-notes-with-dnscache-goodness</link>
		<comments>http://www.computersolutions.cn/blog/2009/11/openvpn-setup-notes-with-dnscache-goodness/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 00:00:20 +0000</pubDate>
		<dc:creator>Lawrence Sheed</dc:creator>
				<category><![CDATA[Technical Mumbo Jumbo]]></category>
		<category><![CDATA[dnscache]]></category>
		<category><![CDATA[openvpn]]></category>

		<guid isPermaLink="false">http://www.computersolutions.cn/blog/?p=286</guid>
		<description><![CDATA[Setting up OpenVPN was a real PIA for a number of reasons DNS, crap documentation, and general issues with vpn clients. My working notes are below: Install OPENVPN from tar.gz or apt-get install&#8230; Generate key&#8217;s etc (tons of other tutorials on that) Prelim info My vpn server has a static ip address, in the 66.xx [...]]]></description>
			<content:encoded><![CDATA[<p>Setting up OpenVPN was a real PIA for a number of reasons DNS, crap documentation, and general issues with vpn clients.  </p>
<p>My working notes are below:</p>
<p>Install OPENVPN from tar.gz or apt-get install&#8230;<br />
Generate key&#8217;s etc (tons of other tutorials on that)</p>
<p><strong>Prelim info</strong><br />
My vpn server has a static ip address, in the 66.xx range.  Our local client machines use a 192.x range (typically).<br />
I setup a tun address for 10.1.0.1 for the server.</p>
<p>As we don&#8217;t want to have routing issues, I set openvpn to use the 10.x range for any vpn connections.<br />
(Essentially all clients connected to the openvpn ip will get a 10.1.0.x address).</p>
<p>I also force clients to use our DNS server (more on that later), as China does some DNS lookup interceptions which break stuff if you are using a tunnel. I also don&#8217;t use openvpn on the standard port 1194, as I was seeing mysterious tcp resets when using the common vpn ports. Amazing how that happens in China.  Lastly, I&#8217;ve put in on port 8080 for our users, as this seems to work without issue.  </p>
<p>To do all that, I created an openvpn.conf file with the following:</p>
<p><code>port 8080<br />
#proto tcp<br />
#dev tun<br />
proto udp<br />
dev tap<br />
ca keys/ca.crt<br />
cert keys/server.crt<br />
key keys/server.key<br />
dh keys/dh1024.pem<br />
server 10.1.0.0 255.255.255.0<br />
ifconfig-pool-persist ipp.txt<br />
keepalive 10 120<br />
comp-lzo<br />
user nobody<br />
group users<br />
persist-key<br />
persist-tun<br />
status /var/log/openvpn-status.log<br />
verb 3<br />
client-to-client<br />
push "redirect-gateway"<br />
push "dhcp-option DNS 10.1.0.1"<br />
link-mtu 1456<br />
mssfix 1412<br />
cipher AES-256-CBC</code></p>
<p>(You can read the standard install stuff for your own key generation)</p>
<p>Next we need to tell our server to route stuff appropriately for vpn traffic</p>
<p><code>echo 1 > /proc/sys/net/ipv4/ip_forward<br />
iptables -A INPUT -p udp --dport 8080 -j ACCEPT<br />
iptables -A INPUT -i tun+ -j ACCEPT<br />
iptables -A FORWARD -i tun+ -j ACCEPT<br />
iptables -A INPUT -i tap+ -j ACCEPT<br />
iptables -A FORWARD -i tap+ -j ACCEPT<br />
iptables -t nat -A POSTROUTING -s  10.1.0.0/24 -o eth0 -j MASQUERADE</code></p>
<p>(You&#8217;ll need to change the 10.1.0.0 to your actual vpn user subnet if you change in the openvpn.conf)</p>
<p>OpenVPN should start, and be connectable.</p>
<p>My client config looks approximately something like this:</p>
<p><code>client<br />
dev tap<br />
proto udp<br />
remote mysupersekritvpnserver.com 8080<br />
comp-lzo<br />
verb 3<br />
mute 20<br />
nobind<br />
persist-key<br />
persist-tun<br />
cipher AES-256-CBC<br />
ca ca.crt<br />
cert my.crt<br />
key my.key</code></p>
<p>my.crt, my.key, ca.crt should be copied / generated from the server, and copied over to the client machine.<br />
mysupersekritvpnserver.com should be changed to your server name.<br />
We use Mac&#8217;s mostly, so we use tunnelblick, copy that config in, check the &#8220;Set NameServer&#8221; box in Details.</p>
<p>You should be able to connect now and ping remotely with that.<br />
Next, we need to setup DNS</p>
<p>For the longest time I couldn&#8217;t get this working, despite me reading and re-reading the doc&#8217;s.</p>
<p>We use dnscache for dns lookups on our servers. DNS Cache allegedly allows lookups from other ip addresses by sticking whats allowed into /etc/dnscache/root/ip</p>
<p>This wasn&#8217;t working at all.</p>
<p>Eventually I twigged that dnscache binds to one ip address, and ignores the others, which is why local lookups worked, but tunnel started ones didn&#8217;t.</p>
<p>Took me a while to see that though.  Was only when I did an nmap 10.1.0.1 and saw port 53 was closed, that I realised, despite the misleading fscking documentation which says &#8220;just add the ip address for the computers allowed to connect&#8221; to the dnscachefolder/root/ip, you really need to bind it to all the ports you will want lookups to work for.</p>
<ul>Which is not clearly mentioned in any documentation I saw on the net.</ul>
<p>I ended up making another dnscache specifically for our tun address on 10.1.0.1, and telling it to allow queries from the actual server ip 66.x, and from 10.x, *then* it started working.</p>
<p>Hours of fun and joy.</p>
<p>Worth it though, I can now connect to bookface and toobyou, yay!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.computersolutions.cn/blog/2009/11/openvpn-setup-notes-with-dnscache-goodness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

