Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Update host info with Cisco VPN IP info Network
Some places, like universities, require that you be connected to their VPN servers in order to do stuff like check email through a non-webmail client or access certain resources they give you. My school uses the Cisco VPN Client. So I just leave the VPN connection up and running constantly. But sometimes I want to be able to connect to my home machine from on-campus machines. Normally, this would require that I write down my VPN IP address, since there's no existing mechanism for updating a DynDNS hostname with an IP address assigned by Cisco's VPN Client. That is, until now.

Here's a quick sub-hint. If you don't want to deal with the Cisco VPN GUI being open in your Dock all the time, use the command line client. Open your Terminal and type screen and press Enter. This will take you to a new screen session. Press Enter again after reading all about the wonderful screen utility. At the new prompt, type vpnclient connect [profile_name]. Enter your username and password to connect. Once you've established the connection, you detach the screen session by pressing Control-A and then Control-D. The first keeps the session active in the background, and the second detaches the screen into its own background process. You can then quit the Terminal. If you want to check back in with your screen session, type screen -r.

Okay, on with the real hint. I started with the DNS updater utility in this hint, written by Robert Miller, and modified it (view source) to grab the IP outputted by the command line VPN client. Most of the commented-out code was my experimentation with Keychain integration. Unfortunately, unlocking the Keychain requires a graphical context, which this utility does not have when run as a periodic process with cron or launchd. (I will cover setting this up later in the hint.)

So I made the code as secure as I could and designed the source so that the password had to be hard-coded at compile time. Not an ideal or even good solution, but at least the password isn't being passed as a plain-text parameter into the utility. (Though if you want to make it behave that way, the changes required are pretty trivial.) But as it stands now, just look for YOUR_PASSWORD_HERE and replace it with your password for your account.

Anyway, once you've put your password in the source, you need to compile it. Open your Terminal to the directory where the source resides and run the following command:
g++ dyndns_vpn.cpp -o dns_update
This will generate an executable named dns_update. You can put this executable wherever you want, but I recommend creating a bin directory in your Home directory and dropping it there.

Now we want this updater to run periodically. So for Tiger users, you want to use launchd. For this, you'll need to create a .plist. I've got a template posted here. Once you've downloaded and modified the .plist according to the quasi-instructions included, rename it to something that makes sense, like and drop it in /Library/LaunchAgents/. launchd should automatically register the job and run it every 300 seconds. Note that the update is coded in such a way that it will only send an update request if the IP assigned to your hostname is different from the one your VPN connection currently has. So you don't have to worry about your account being suspended due to excessive activity. You can change the run interval to be as frequent as you want.

For Panther users and earlier, you'll have to set up a cron job. To do this, I recommend the excellent Cronnix, a GUI front-end to cron.

This utility does support logging, so you can set its standard out in cron or launchd to be whatever log file you want. It will log its actions every time it is run and what it changed your IP to, if that was necessary.

If you'd like to take the utility for a test run to make sure it's working properly, you can run it from the Terminal with the following syntax:
./dns_update [user] [host]
So if your username is joedns with the host, you'd run the following:
./dns_update joedns
Well that's about it. Hope this proves as useful for others as it did for me...
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)

Update host info with Cisco VPN IP info | 3 comments | Create New Account
Click here to return to the 'Update host info with Cisco VPN IP info' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Update host info with Cisco VPN IP info
Authored by: tbender on Sep 14, '05 12:18:05PM

The DynDNS Updater h**p:// </b> is able to do the sam, if you set the host preferences on external ip.

[ Reply to This | # ]
Update host info with Cisco VPN IP info
Authored by: Durandal on Sep 14, '05 10:22:40PM

Cisco doesn't set up an interface that actually registers on the outside. So the DynDNS Updater can't really detect it.

Damien Sorresso

[ Reply to This | # ]
Update host info with Cisco VPN IP info
Authored by: tbender on Sep 15, '05 04:39:10AM

I'm using Cisco VPN Client 4.6.04 and DynDNS Updater. And it really works (but I dont know how) ...

[ Reply to This | # ]