QuickSwitch - Roaming network profiles for Unix/Linux Laptops.
Mohit Muthanna / Paul Seamons
$ emerge app-admin/quickswitch


Check out TeleAuth, a free Two-Channel/Two-Factor Authentication System.


QuickSwitch is a utility that lets Linux/Unix laptop users create and use roaming network profiles. Instead of individually reconfiguring the network card, changing DNS entries, hosts files etc. it lets you create one centralized file for all your different profiles. QuickSwitch has been around since early 2000 and is now the most widely used utility of its kind.

QuickSwitch is a winner of DaveCentral's Best of Linux Award and also in Linux.com's "Best of Linux" Archive. See details here.

NEW: A bunch of cool user contributed patches to quickswitch. These will make it into the next quickswitch release (as soon as I find some time) - 7/Oct/04.

Current stable version: 1.05.

Note: For those complaining about quickswitch not working with Redhat 9 (or any distro with new perl versions), get version 1.05 or higher of quickswitch.

A big thanks to Paul T. Seamons for cleaning and fixing up the core code.

Getting QuickSwitch

The latest QuickSwitch distribution can be downloaded from the files section of the sourceforge project page. Click here.

There's also a bunch of cool user-contributed patches: patches/

Features

Selecting profiles is as simple as typing in "switchto home" or "switchto work" on the command line. Other ways you can use it is via the one-time configuration like:

> switchto ip:192.168.1.12 netmask:255.255.255.0 gw:192.168.1.51 dns1:192.168.1.51

Or on bootup using a kernel parameter in LILO or GRUB:

LILO: linux SWITCHTO=work

You can also use the curses based GUI simply by invoking switcher.

It's other features are:

- ANSI colors to easily decipher debug messages. Looks funky too.
- Dynamic file switching through the [files] section. Now switch any configuration file around.
- Support for multiple network cards
- Wireless LAN configuration
- Configuration through Kernel parameters
- DHCP / BOOTP support
- NFS shares / NIS domain support
- Support for /etc/printcap, X configuration, Netscape preferences, Samba shares etc. through the new dynamic file switching feature.
- Curses based GUI. Gnome GUI. Gnome Tray Applet.
- Command line onetime configuration.
- Pre and post execute scripts before or after changing profiles
- Extremely easy to use

Sample Output (text mode)

Sample Output (GUI)

Sample Output (Gnome Tray Applet)

Details about the Gnome Tray Applet here.

Project Page

A big thanks to Source Forge for their superior project management services. The QuickSwitch project page can be accessed at sourceforge.net/projects/quickswitch.

Installing

Prerequsites: Perl 5, Awk and root access.

Untar the distribution package:

> cd /usr/local
> su -
(Type root password here)
> tar -zxvf quickswitch-0.1.2-linux-intel.tar.gz

Run the install script:

> cd quickswitch
> ./INSTALL.sh

Configuring

Setting up QuickSwitch is a piece of cake. Just edit the /etc/switch.conf file using the sample provided and you're ready to go. Remember to switch to root before using it.

There is also an article on using QuickSwitch that covers most of it's features - http://www.newsforge.com/article.pl?sid=01/12/22/2118213

Setting a profile and backing up original files (/etc/hosts, resolv, exports etc..):

> switchto -b MyProfile

QuickSwitch options are detailed as follows:

-l: Lists all available service profiles setup in the configuration file. eg:

> switchto -l
QuickSwitch v0.1 Mohit Muthanna 2000
Available service profiles:
Home
ITS
Prodigy

-d : Set debug (logging) level. Logs are sent to standard output. Levels can be 1 or 2. 2 just produces more output. eg:
-b: Backs up original files. (At the time of this writing, /etc/hosts, /etc/resolv.conf, exports and anything in the files section).
-s: Uses kernel supplied SWITCHTO parameter or last good known configuration.

Using QuickSwitch in Commandline Mode

Using the commandline feature is great for one-time configs. Here's an example:

> switchto ip:192.168.1.12 netmask:255.255.255.0 gw:192.168.1.51 dns1:192.168.1.51

The understood parameters are:

ip: Ip Address (eg. ip:192.168.1.12)
netmask: Subnet mask (if any)
gw: Default gateway
domain: Domain Name
dns1/dns2: Pri / sec DNS address
host: Hostname
fqhost: Fully Qualified hostname
essid: Wireless LAN essid
key: Wireless LAN key

Note: If you don't specify a hostname or Fully qualified hostname, the /etc/hosts file is left untouched.

Using the Kernel Parameter feature

Using the -s switch, Quickswitch can select a profile based on a supplied kernel parameter. Eg., in the LILO prompt on startup, you can type "linux SWITCHTO=home".

To enable this, add the line "/usr/bin/switchto -s" into your rc.local or similar startup file.

If no parameter is supplied during startup, quickswitch uses the last working configuraions. See servicefilename in switch.conf for details on this.

Using the dynamic file switching feature

With version 0.12 there is a new [files] section where you can add names of files you want dynamically switched. In this section you should add the original names of the files you want switched as shown:

[files]
samba=/etc/smb.conf
printcap=/etc/printcap
netscapeprefs=/home/mohit/.netscape/preferences.js

The text on the left hand side of the '=' can be anything you want as long as it does not conflict with a QuickSwitch reserved word. This text is used as an identifier (inside a profile) for the file you want switched. If inside a profile you want a file switched, simply enter the same information in the profile using the NEW file name, eg.,

[home]
ip=192.168.0.232
netmask=255.255.255.0
...
...
printcap=/etc/printcap.home
preferences=/home/mohit/.netscape/preferences.js.home

Only names entered in the profile will be switched with the original names in the files section.

Using the GUI

Quickswitch comes with a curses based text GUI named switcher which serves as a graphical profile selector. Just add it to your rc.local or similar startup file, or run it from the command line. In order to use the GUI you will need the Perl Curses and Curses::Widgets modules installed.

Lars Trieloff has written a very cool gnome tray applet (for the notification area) as a replacement for Switcher. He's also written Zenity/Gdialog/Xdialog scripts to do the same thing. Details here.

Additional Documentation

The NewsForge article on using QuickSwitch - http://www.newsforge.com/article.pl?sid=01/12/22/2118213

Anonymous CVS Access

This project's SourceForge CVS repository can be checked out through anonymous (pserver) CVS with the following instruction set. When prompted for a password for anonymous, simply press the Enter key.

cvs -d:pserver:anonymous@cvs.quickswitch.sourceforge.net:/cvsroot/quickswitch login
cvs -z3 -d:pserver:anonymous@cvs.quickswitch.sourceforge.net:/cvsroot/quickswitch co quickswitch

Updates from within the module's directory do not need the -d parameter.

Credits

Kernel params hack: Stuart Menefy
Wireless LAN hack: NeilFred Picciotto
Everything else: Mohit Muthanna and Paul T. Seamons

Disclaimer

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to:

Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.