Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
144 lines (129 sloc) 4.79 KB
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<meta content="text/html; charset=ISO-8859-1"
<title>netschemes and netutils: network schemes in Python</title>
<meta content="Akkana Peck" name="author">
<style type="text/css">
pre,code { color: rgb(153, 0, 0); }
.cmd { color: rgb(153, 0, 0); font-weight: bold }
<body bgcolor="white" alink="#000099" link="#000099" vlink="#990099">
<img alt="[tux networking]" src="/images/logos/tuxnetwork.jpg"
align="right" height="187" width="256">
<h1>netschemes and netutils</h1>
<h2>Howto Set Up Multiple Network Schemes on a Linux Laptop</h2>
... and ...
<h2>a Python networking utility library</h2>
As you take your laptop from one network to the next, from home
to work or from the coffee shop to the conference, how do you
tell it about each new network?
Modern Linux systems come with nifty GUI programs such as
<i>NetworkManager</i> and <i>wicd</i>, but I find them slightly
cumbersome and hard to use. I find they're always trying to
out-guess me about what network I really want to use, and they
don't work terribly well with a lightweight desktop.
I find it much faster to type one command, like <b>netscheme home</b>
or <b>netscheme work</b>, for networks I use a lot, and save all the
fiddling with menus.
This page covers two topics:
<li><a href="#netscheme"><b>Using</b> the high-level "netscheme" script</a>
<li><a href="#netutils">The <b>Python ""</b> network utility module</a>
<a name="netscheme">
<h2>Using netscheme</h2>
You need two Python scripts: <a href="netscheme-1.4">netscheme-1.4</a> and
<a href=""></a>.
Put them somewhere in your path and name them netscheme and
I put them in $HOME/bin, my personal bin directory, but somewhere like
/usr/local/bin is also fine.
By default, netscheme knows about two schemes.
The first, "dhcp", will try to set up a connection using your first wired
ethernet port (e.g. eth0) and a DHCP address. To use it, type:
sudo netscheme dhcp
The second built-in scheme, "wifi", is also DHCP, but uses
your first wireless connection (typically wlan0 or eth1).
This works on some networks, but most wireless networks will require
that you specify a network name (SSID).
To set up your own custom schemes for places you go, create a file in
your home directory called <b>.netscheme</b> containing entries like this:
dhcp = false
ip =
netmask =
broadcast =
gateway =
dns_servers =,
encryption = open
essid = coffeehouse-wifi
encryption = wpa
essid = MyWorkWPA
key = secretpassword
DHCP is the default, but you can set it to false and use static addresses.
<code>netscheme</code> with no arguments will try to figure out the
current scheme. (For a wired scheme with no essid, it may not be sure.)
<code>netscheme schemename</code> will switch to that scheme.
<code>netscheme essid</code> will try to connect to the given wireless
network, and will ask whether you want to save that as a scheme for later.
<tr><td>--version <td>show program's version number and exit
<tr><td>-h, --help <td>show this help message and exit
<tr><td>-l, --list <td>List the known schemes
<tr><td>-a, --accesspoints <td>List available accesspoints
<tr><td>-m, --multi <td>Add a new interface without bringing down current one
<a name="netutils">
<h2> a Python module for handling networking</h2>
<p> is the heart of netscheme. It consists primarily of
wrappers around system utilities like <i>ifconfig</i>,
<i>iwconfig</i>, <i>iwlist</i>, <i>route</i>, <i>modprobe</i> and so on,
but it presents a much cleaner Python interface so you don't have to
deal with those underlying details.
Download it: <a href=""></a>
Documentation for it (generated with pydoc) is available here:
<a href="netutils-1.4.html">Python networking module</a>.
If you have a wishlist for functions you'd like to see in, or ways you think I should change the API, don't
hesitate to <a href="/mailme.html">let me know!</a>
<h2>Ancient history</h2>
For historical reasons I've left the
<a href="/linux/networkSchemes-deb.html">Debian/Ubuntu-specific
network schemes</a> page online. It includes some possibly helpful
though also partly obsolete information about Debian's
/etc/network/interfaces mechanism, and maybe even a bit of even more
obsolete information about networking under old Redhat systems.
<a href="../">More software</a><br>
<a href="/linux">Linux Links</a><br>
<a href="/">Shallow Sky Home</a><br>