February 02, 2008

Getting vpnc to work on OpenSolaris

I haven't found a recipe of how to get the vpnc project to work on OpenSolaris. So when I found one that worked for me I figured I'd post it, even though I don't know if it will work on Solaris 10, on other builds of OpenSolaris, or even on your computer given the exact same build I'm using. (I'm still a Solaris newb.) So YMMV.

My setup:

1) Install some dependencies with Blastwave:

 $ pkg-get -i binutils
 $ pkg-get -i libgcrypt
 $ pkg-get -i intltool
 $ pkg-get -i libiconv
 $ pkg-get -i gnupg
 $ pkg-get -i tun
 $ pkg-get -i gcc3

2) Put gcc on your PATH (assuming you're using bash):

 $ export PATH=$PATH:/opt/csw/gcc3/bin

3) Download vpnc-0.5.1

4) Unpack vpnc, cd into the directory

5) Open 'Makefile' in your favorite text editor and change all calls of 'install' to 'ginstall' (don't change the make targets, just the invocations)

6) Make and install:

 $ gmake
 $ gmake install

7) If they're not already there, add some items to your path (you'll need this permanently):

 $ export PATH=$PATH:/usr/local/bin:/usr/local/sbin

8) Create the directory for vpnc to store files:

 $ mkdir /var/run/vpnc

9) Modify the first line of the following files to use '#!/usr/bin/bash' instead of '#!/bin/bash':

    /usr/local/sbin/vpnc-disconnect
    /etc/vpnc/vpnc-script

10) Update the 'route add' statements in /etc/vpnc/vpnc-script on lines 164, 175, 183 and 189 by appending ' -interface'

11) Create your config. You can use the bundled 'pcf2vpnc' script (installed to /usr/local/bin) to translate the Cisco profile your company provides to a vpnc configuration:

 $ pcf2vpnc Your-Company-Profile.pcf > /etc/vpnc/Your-Company.conf

12) Fire it up!

 $ vpnc Your-Company.conf

13) You can see that it's working by listing your interfaces:

 $ ifconfig -a
 ...
 tun0: flags=10010008d1<UP,POINTOPOINT,RUNNING,NOARP,\
MULTICAST,IPv4,FIXEDMTU> mtu 1412 index 7
        inet 172.16.6.170 --> 172.16.6.170 netmask ffffffff
        ether eb:d5:90:b2:eb:d5

or printing your route table:

 $ netstat -nrv

14) Other useful resources:

Next: Impressions of OpenSolaris
Previous: More shit I can do without