Make Your Laptop Settings Roam with Laptop-net
Kyle Rankin
Quinstreet Inc.
The Problem
- Laptops becoming more powerful
- Laptop commonly primary computer
- The Network is everywhere!
- but...
- Your settings are often network-specific:
- Network printer
- Hosts file
- Firewall
- Browser/Email
- Etc.
A Solution: Laptop-net
Laptop-net allows you to:
- Use settings on a per-network basis:
- Default printer
- /etc/hosts
- NFS/SMB mount points
- Firewall
- Browser (proxy vs. no proxy)
- Email + MTA settings
- Run scripts on a per-network basis:
- Automatically sync/backup files
- Set up tunnels/proxies
- Mount/umount network filesystems
- Change desktop background :)
- Pretty much anything
How Laptop-net Works
- Activates after you get an IP
- Compares the IP with pre-configured IP patterns for a match
- Copies config files for the matching profile to system
- Executes a script in the matching profile
Install Laptop-net
- Debian-based distributions only
- Install Laptop-net package
# apt-get install laptop-net laptop-net-doc
- Reconfigure laptop-net to disable MII (especially for NetworkManager):
# dpkg-reconfigure laptop-net
- Use DHCP
- Don't use MII (even if supported)
- Restart laptop-net:
# /etc/init.d/laptop-net restart
Write DHCP Script
Use DHCP script to automatically launch laptop-net when getting/releasing a lease
- Create a file named /etc/dhcp3/dhclient-exit-hooks.d/laptop-net:
if [ $reason = 'BOUND' ]; then
/usr/share/laptop-net/profile-change $interface
fi
if [ $reason = 'RELEASE' ]; then
/usr/share/laptop-net/profile-change $interface down
fi
Fix Possible Bug
If /var/run/laptop-net isn't being created:
Configure laptop-net Profiles
Profiles have a few important files/directories:
- patterns
- files.d/
- after-select
- before-deselect
Configure laptop-net Profiles
Offline Profile
Configure laptop-net Profiles
Default Network Profile
Configure laptop-net Profiles
Test Your Profiles
- Deactivate network connection and cat /tmp/laptop-net-state (should say "offline")
- Activate network connection and cat /tmp/laptop-net-state (should say "zzz-default")
- Monitor laptop-net in /var/log/syslog:
Mar 4 16:12:56 ubuntu laptop-net: Selecting network profile "zzz-default"
Mar 4 15:19:42 ubuntu laptop-net: Deselecting network profile "zzz-default"
Mar 4 15:19:42 ubuntu laptop-net: Selecting network profile "offline"
Mar 4 15:24:06 ubuntu laptop-net: Deselecting network profile "offline"
Mar 4 15:24:07 ubuntu laptop-net: Selecting network profile "zzz-default"
Configure laptop-net Profiles
Home Profile
Configure laptop-net Profiles
Work Profile
Make Your Default Printer Roam
- Configure printer settings and set the default printer for a profile
- copy /etc/cups/printers.conf to /etc/laptop-net/profiles/profilename/files.d/etc/cups/printers.conf
- Edit after-select script for the profile and add:
/etc/init.d/cupsys restart
- Copy above steps for any other profiles you want to have a default printer
Questions?