First off, I'm new to OpenSolaris so I don't know where best to send
this email, so I'm sending it to opensolaris-help at opensolaris.org.

Problem: OpenSolaris 2009.06/Indiana does not come with vtun
(http://vtun.sourceforge.net/tun/index.html) and has no mainstream
package for it (The packages on Blastwave were insufficient). This is
needed to properly use OpenVPN. I couldn't exactly find the solution
on the web, as they all gave a "failed to attach" from devfsadm -i tun
with my 64-bit kernel. Here's the solution I finally figured out, done
on a fresh install of OpenSolaris 2009.06:

$ pfexec pkg install SUNWgcc
$ cd $HOME
$ wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.03.tar.gz
$ tar xzvf lzo-2.03.tar.gz
$ cd lzo-2.03
$ ./configure
$ make
$ pfexec make install
$ cd $HOME
$ wget http://www.whiteboard.ne.jp/~admin2/tuntap/source/tuntap/tuntap.tar.gz
$ tar zxvf tuntap.tar.gz
$ cd tuntap

Now you need to change the configure.in and Makefile.in file to make
sure the drivers are also loaded onto the /platform directory, and add
module compilation support.

** change this part of configure.in file:
---------------------------------------------------
case $KARCH in
     'sparc' | 'i386')
        DRV_DIR="/usr/kernel/drv"
        PLAT_DRV_DIR="/platform/`uname -m`/kernel/drv"
        ;;
      'sparcv9')
        CFLAGS="$CFLAGS -m64"
        DRV_DIR="/usr/kernel/drv/sparcv9"
        PLAT_DRV_DIR="/platform/`uname -m`/kernel/drv/sparcv9"
        if test -n "$IS_GNU_LD";
        then
                LD_OPT="-melf64_sparc"
        fi
        ;;
      'amd64')
        if test "$GCC" = yes; then
                CFLAGS="$CFLAGS -m64 -mcmodel=kernel -mno-red-zone"
        else
                CFLAGS="$CFLAGS -m64 -xmodel=kernel"
        fi
        DRV_DIR="/usr/kernel/drv/amd64"
        PLAT_DRV_DIR="/platform/`uname -m`/kernel/drv/amd64"
        if test -n "$IS_GNU_LD";
        then
                LD_OPT="-melf_x86_64"
        fi
        ;;
esac
---------------------------------------------------

** change these parts of the Makefile.in file:
---------------------------------------------------
DRV_DIR = @DRV_DIR@
DRV_CONF_DIR = /usr/kernel/drv
PLAT_DRV_DIR = @PLAT_DRV_DIR@
PLAT_DRV_CONF_DIR = "/platform/`uname -m`/kernel/drv"

....

modules: tun.o tap.o
        $(LD) $(LD_FLAGS) -r -o tun tun.o
        $(LD) $(LD_FLAGS) -r -o tap tap.o

....

install: tun tap
        $(INSTALL) -d -m 0755 -o root -g bin $(DESTDIR)/usr/include/net
        $(INSTALL) -d -m 0755 -o root -g sys $(DESTDIR)$(DRV_DIR)
        $(INSTALL) -d -m 0755 -o root -g sys $(DESTDIR)$(PLAT_DRV_DIR)
        $(INSTALL) -m 644 -o root -g root if_tun.h $(DESTDIR)/usr/include/net
        $(INSTALL) -m 644 -o root -g root tun $(DESTDIR)$(DRV_DIR)
        $(INSTALL) -m 644 -o root -g root tap $(DESTDIR)$(DRV_DIR)
        $(INSTALL) -m 644 -o root -g root tun $(DESTDIR)$(PLAT_DRV_DIR)
        $(INSTALL) -m 644 -o root -g root tap $(DESTDIR)$(PLAT_DRV_DIR)
        $(INSTALL) -m 644 -o root -g root tun.conf $(DESTDIR)$(DRV_CONF_DIR)
        $(INSTALL) -m 644 -o root -g root tap.conf $(DESTDIR)$(DRV_CONF_DIR)
        $(INSTALL) -m 644 -o root -g root tun.conf
$(DESTDIR)$(PLAT_DRV_CONF_DIR)
        $(INSTALL) -m 644 -o root -g root tap.conf
$(DESTDIR)$(PLAT_DRV_CONF_DIR)
        -[ -z "$(DESTDIR)" ]&& $(REM_DRV) tun >/dev/null 2>&1
        -[ -z "$(DESTDIR)" ]&& $(REM_DRV) tap >/dev/null 2>&1
        -[ -z "$(DESTDIR)" ]&& $(ADD_DRV) tun
        -[ -z "$(DESTDIR)" ]&& $(ADD_DRV) tap

uninstall:
        -[ -z "$(DESTDIR)" ]&& $(REM_DRV) tun >/dev/null 2>&1
        -[ -z "$(DESTDIR)" ]&& $(REM_DRV) tap >/dev/null 2>&1
        -[ -z "$(DESTDIR)" ]&& $(RM) $(DESTDIR)$(DRV_CONF_DIR)/tun.conf
        -[ -z "$(DESTDIR)" ]&& $(RM) $(DESTDIR)$(DRV_CONF_DIR)/tap.conf
        -[ -z "$(DESTDIR)" ]&& $(RM) $(DESTDIR)$(PLAT_DRV_CONF_DIR)/tun.conf
        -[ -z "$(DESTDIR)" ]&& $(RM) $(DESTDIR)$(PLAT_DRV_CONF_DIR)/tap.conf
        -[ -z "$(DESTDIR)" ]&& $(RM) $(DESTDIR)$(DRV_DIR)/tun
        -[ -z "$(DESTDIR)" ]&& $(RM) $(DESTDIR)$(DRV_DIR)/tap
        -[ -z "$(DESTDIR)" ]&& $(RM) $(DESTDIR)$(PLAT_DRV_DIR)/tun
        -[ -z "$(DESTDIR)" ]&& $(RM) $(DESTDIR)$(PLAT_DRV_DIR)/tap
---------------------------------------------------

Now we can do:

$ ./configure
$ make
$ pfexec make install
$ cd $HOME
$ wget http://www.openvpn.net/release/openvpn-2.1_rc20.tar.gz
$ tar xvzf openvpn-2.1_rc20.tar.gz
$ cd openvpn-2.1_rc20
$ wget 
http://www.whiteboard.ne.jp/~admin2/tuntap/source/openvpn/2.1/patch.openvpn.2.1_rc16.tun.c
$ patch tun.c patch.openvpn.2.1_rc16.tun.c
$ ./configure -with-lzo-lib=/usr/local/lib
$ make
$ pfexec make install
$ pfexec ln -s /usr/local/share/man/man8/openvpn.8 /usr/share/man/man8/openvpn.8

And you can find the openvpn binary installed in
/usr/local/sbin/openvpn. Note this is not part of the default PATH env
variable.

I'd also like to thank Stefan Reuter from
http://blogs.reucon.com/srt/2008/12/17/installing_openvpn_on_opensolaris_2008_11.html.

Cheers,

Matthew Carras
aka "Thrae"

PS: Here's a little /etc/init.d script I'm using until I can figure
out how to make a scvs configuration:

---------------------------------------------------
#!/sbin/sh
#openvpn.client

case "$1" in
'start')
        echo 'Starting daemonized OpenVPN client'
        /usr/local/sbin/openvpn --daemon --writepid
/tmp/openvpn.client.pid --cd /etc/openvpn/ --config
/etc/openvpn/client.conf
        ;;

'stop')
        echo 'Killing daemonized OpenVPN client'
        kill `cat /tmp/openvpn.client.pid`
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;
esac
---------------------------------------------------

Reply via email to