Logging onto CSU's VPN

If you are lucky enough to have a network drive at CSU, you'd probably be very happy to be able to able to mount it from FreeBSD rather than just Windows. Fortunately, we can do just that.

Connecting to the VPN
Mounting Network Drives
Passwordless Mounting

Connecting to the VPN

Before we can mount our network drives, we will have to connect to the VPN. Fortunately this is a simple process. First we'll install vpnc. Of course you must be root to do so.

cd /usr/ports/security/vpnc
make install clean

Now that it is installed, we'll modify the configuration file.

cd /usr/local/etc
cp vpnc.conf.sample vpnc.conf
vi vpnc.conf

We copied rather than renamed the config file so we'll have the default just in case we need it for future reference. There are two different configurations, depending on whether you are connecting to the regular vpn, or if you are connecting to the engineering vpn. First, the regular vpn:

Interface name tun0
IPSec gateway 129.82.80.2
IPSec ID csuvpn2
IPSec secret colostate
Xauth username reinholz
Xauth password PASSWORD

In this file you will need to alter the last two lines. Change reinholz to your eid, and PASSWORD to your corresponding password. Alternatively, if you want to connect to the engineering vpn, use this configuration:

Interface name tun0
IPSec gateway 129.82.80.2
IPSec ID ENGR
IPSec secret engr
Xauth username Engr_dom\reinholz
Xauth password PASSWORD

Now of course you will need to change reinholz to your user name for your engineering account, and PASSWORD to your password. Alternatively you may omit the last line, but you will be prompted for your password everytime you start vpnc. Now that our configuration is set, run this command to log in. Remember you will always need to run vpnc as root.

vpnc

After doing so you will see a nice welcome message (for the engineering vpn).

bsd# vpnc
Connect Banner:
| Welcome to ENGR VPN.
|
|

add host 129.82.80.2: gateway 192.168.1.1
delete net default
add net default: gateway 129.82.18.81
VPNC started in background (pid: 58551)...

Now let us make some use out of this VPN connection...

Mounting Network Drives

In order to mount your network drives you must first be connected to the VPN. I'll assume you've gone through the previous section and done so already. First let's make some directories to mount the network drives in (this example is for the engineering vpn, modify it accordingly for another server, such as math).

mkdir /engr /engr_classes
chown xaenn /engr /engr_classes

Of course replace xaenn with the name of your user account. Now let's mount the drives.

mount_smbfs -I bluestore.engr.colostate.edu -W ENGR_DOM //reinholz@bluestore/reinholz /engr
mount_smbfs -I bluestore.engr.colostate.edu -W ENGR_DOM //reinholz@bluestore/classes /engr_classes

After each of those commands you will be prompted for your password. Now enjoy using your network drive from inside FreeBSD. If you have a math network drive, on the other hand, the command will look like this:

mount_smbfs -I cantor.math.colostate.edu -W MATH2 //reinholz@cantor/reinholz /math

In this command reinholz is your username, and /math is a directory on your computer.

Passwordless Mounting

That's fine and good that we've got our network drive mounted, but the process isn't nearly as clean as it could be. Fortunately, we can setup our shares in fstab, configure mount_smbfs, and finally write a simple script to streamline the process.

vi /etc/fstab

Add two lines to the very bottom (for engineering):

//reinholz@bluestore/reinholz /engr smbfs rw,noauto 0 0
//reinholz@bluestore/classes /engr_classes smbfs rw,noauto 0 0

For math:

//reinholz@cantor/reinholz /math smbfs rw,noauto 0 0

Now that we've done that we need to setup some options for mount_smbfs.

touch ~/.nsmbrc
chmod 600 ~/.nsmbrc
vi ~/.nsmbrc

We just created a new file, and made it so nobody but root can read or write it, (your passwords will be in here, so you don't want anybody else to have access to them) and opened it up for editing.

[BLUESTORE]
addr=bluestore.engr.colostate.edu
workgroup=ENGR_DOM

[BLUESTORE:REINHOLZ]
password=PASSWORD

I know that the syntax is a bit cumbersome, but it is due to the restrictions on how you must enter information. Make sure that your username is all caps in the same place that mine is. If you want to do this for math, you need to layout the file in a similar but different way:

[CANTOR]
addr=cantor.math.colostate.edu
workgroup=MATH2

[CANTOR:REINHOLZ]
password=PASSWORD

Now we'll write a quick little script to do this process (for engineering). First become user however (that way we'll make the script in our user's home directory).

cd ~/bin
touch engr_mount
chmod 755 engr_mount
vi engr_mount

We just created the script, and then made it executable.

#!/bin/sh
vpnc
mount /engr
mount /engr_classes

The script is very simple, and one could make it run at startup, but I'd prefer not to. I don't always need the vpn, and I'm not always online. One final note is that even though you made the script in your user's home directory, you will need to run it as root (don't worry, when you su ~/bin will still be in your path).