Sunday, July 31, 2011

OpenVPN on Windows 7

I have always had a problem with OpenVPN on my Windows 7 (64 bit, pro edition) laptop. Installing would go just fine, but it was never able to connect to the VPN server, even though I checked on several other computers (even a Windows 7 one) that the settings were correct and working.

VirtualBox
As it turns out, OpenVPN and Oracle VirtualBox on the same computer just doesn't work. Uninstalling VirtualBox would make it possible to connect to my VPN server.

However, I then encountered another issue...

TUN/TAP Driver
If the VPN connection dropped, like due to an unstable wifi link, I could never get it to work after it had reconnected.

After rebooting it would work fine though, so after a bit of fiddling I came up with a workaround. Before reconnecting to the VPN server I have to disable and then re-enable the TUN/TAP network driver. Go figure...

Software Used
  • Windows 7 64 bit professional edition
  • VirtualBox 4.0.10 and 4.1.0
  • OpenVPN 2.2.1

Tuesday, June 28, 2011

Project Firewall - Hardware

NetGear WNDR3700
Yey!

My ISP upgraded my internet connection, and lowered the price at the same time. My initial tought was ofcourse "Fantastic! Woot!!1". And it looked quite good, except I didn't manage to get full download speed on my new connection with my current router, the NetGear WNDR3700.
Don't get me wrong, its a pretty decent piece of hardware, but as most appliances meant for the mass market, it isn't really designed to handle a 60 Mbps fiber connection. My peak download speed was about 5.85 MB/s or about 50 Mbps.

So, out with the old, and in with the new. This time I wanted to be sure my router/firewall would handle the load I put on it, and preferably handle a couple of OpenVPN connections as well. After a shopping spree I ended up with the following hardware purchases:

ZOTAC FUSION350-A-E

All in all it set me back about 3000 NOK (including P&P), a bit expensive for a router, but with the load this should be able to handle I should hopefully not need to buy a new one for a few years!

ANTEC ISK 300-150
I must say I was very impressed by the Antec ISK 300-150 when it arrived. It is one heavy, solid piece of work weighing in at almost 5 kg!

It has room for two 2.5" HDD/SSD drives, as well as a slimline 5.25" CD/DVD ROM drive. Lots of open vents on the side and above the expansion slot and the 80mm fan has 3 adjustable speed settings though a small switch on the rear of the cabinet. Mine is running fine at the slowest setting, and is barely audible.

The mainboard comes with an Atheros based wireless mini-pc-express card for b/g/n networking in addition to the gigabit integrated NIC. Adding the Intel NIC completed my networking requirements with a total of three physical zones (wan, lan and wlan).

I will follow up this post with information about software and performance experiences later on. 

Tuesday, May 10, 2011

.Net Clipboard and the OutOfMemoryException.

I recently had a weird bug that manifested as a first-chance OutOfMemoryException inside Windows.Forms when using the clipboard. At first it doesn't appear to do any harm, except the clipboard did not return the expected data. Unfortunately it had a slight side effect: Any later call using OLE/COM would crash and burn. Bummer!

Some hours debugging later, and it was apparent that the crash was happening consistently by just letting the application idle after putting something on the clipboard. Apparently there was something wrong in the idle mechanism that updates the paste-command button... but what?

So I went surfing teh intarweb! And found this MSDN page from Microsoft explaining how to use the clipboard from a .Net application. Then I noticed this:
To access data from the Clipboard by using versions earlier than .NET Framework 2.0, use the GetDataObject method and call the methods of the returned IDataObject. To determine whether a particular format is available in the returned object, for example, call theGetDataPresent method.
That looked familiar, and indeed the code was using the old way of accessing the clipboard, by first using GetDataObject() and then using GetData() on the result.
Now the page didn't say anything about this way of doing things being deprecated, but I still got that nagging sensation that this was an important clue.

So I set down and create two simple test applications that did the same thing, only each using a different variation of the clipboard API. The applications were simple: put something on the clipboard, and repeatedly try and read it back in a loop.

The result was that using the new (and preferred?) way of clipboard access had no problems. I ran it through a loop of million clipboard accesses without a hiccup. On the other hand, the application using the old variation of the API had a very familiar problem. After some iterations it started throwing the familiar first-chance OutOfMemoryException. What more, the clipboard data stopped being available for the test application. Very similar indeed to the problem in the main application!

A few repeat runs, trying stuff like forced garbage collection (which did not help at all, except the performance went down the drain) a clear pattern emerged: My test application would stop working after 65525 invocations of GetData(). The 65526th time and onward it would just silently fail with the OutOfMemoryException in the debugger output.

65526 is pretty darn close to the magical 0xFFFF 16 bit limit, so allowing for some initialization and general overhead, it seems clear that the old variation of the clipboard API (pre v2.0) is leaking a handler, global resource or otherwise doesn't free up some counter internally.

If you are lucky enough to be able to use the newer version of the .Net API I suggest you do so, and remove any code using the old API, since its quite simply broken!

Thursday, May 5, 2011

OpenVPN 2 Cookbook



I just received a copy of the OpenVPN 2 Cookbook by Jan Just Keijser in my virtual mailbox. At first glance, the 350 pages appears to contain setup- and troubleshooting-guides for the most common usages of OpenVPN on both Linux and Windows platforms (and in some cases MacOS too).

It is available in regular printed form, and digitally in ePub and PDF formats, from Packt Publishing.

From the description of the book:
OpenVPN 2 Cookbook provides solutions to common OpenVPN problems. The book covers everything a system administrator needs to manage and run an OpenVPN network, from point to point networks to troubleshooting.
I will be back with a review once I have had a chance to read through it.

Thursday, February 24, 2011

Free Tail GUI for Windows

Need a tail replacement on your Windows box? Look no further than Log Expert.

It has lots of powerful features such as:
  • regular expression highlighting
  • "columnizer" for well-defined log file formats
  • opensource
  • unicode support
  • plugin support

...to name a few!

The homepage for the source-code: http://logexpert.codeplex.com/