:: choice ::
go green!  go red!  go blue!
random good link:
Foundation for a Free Information Infrastructure
random evil link:
God Hates Fags
random quote:
"Kimmie is liev."
Kim
visit kde.org! visit debian.org!

3 cuteeees

autonet

I felt the need to have a tool which can set up the network on my notebook automatically, so I wrote one. I called it autonet.py, it's written in python and it's for linux. You can download it here, it's free. :)

Here's a link to the freshmeat project page.

If you have a question or comment, please drop me a line.

autonet.py 0.5
================

autonet.py is a small application which looks up existing network configuration
files, probes the network with arping in order to determine if it can connect
and ideally set up a working internet connection and routing.

autonet.py currently supports only ethernet connections.

Debian/GNU Linux and Gentoo style configuration files are supported.

autonet.py requires:
    - python, at least 2.2 (tested with 2.2 and 2.3)
    - the following shell commands:
        - ping
        - arping
        - ifconfig
        - route
        - recommended: fping, which makes the second stage faster


If no internet connection is available, autonet.py will parse each configuration
file, extract different network setups and probe if the network environment 
works with this configuration.

The probing is done with arping. A bogus IP 0.0.0.0 is used in order to get the
network interface up. Then autonet.py tries to arping the gateway. If the gateway
responds the configuration is considered good. At this point there is no routing,
so only hosts within the subnet defined in the configuration is used.

If none of the gateways in the configuration works, the probe gets more 'brutal'
by just setting up the network interface according to the configuration file, and
and ping the gateway. Again, no routes yet.

If a configuration is considered working (gateway is pingable), the route is set
as described in the configuration file. An internet connection should be established
then. This is also checked by pinging k.root-servers.org (as default, override with
--testhost), use an IP address here, as DNS is not handled by autonet (yet?).

There is a special feature in autonet.py for owners of some models of Asus note-
books. The package contains a module which uses two LEDs of the laptop to show
activity. While searching and probing, the blue LED is flashing, if a working con-
figuration is found the orange LED flickers for a second. Also this will only work
if you have the asus module in your kernel, and it has *not* widely been tested.
Have a look at Asus.py for details.


Some common vars can be edited in autonet.py, such as locations of required
programs and some common settings (of which timeout does not even work yet) but in
most cases supplying reasonable commandline arguments should be sufficient.
As Gentoo has slightly different settings, there are two scripts for Gentoo users, 
to make integration into the Gentoo init system easier.


Installation:
--------------

Simple installation for the root user
- - - - - - - - - - - - - - - - - - - - -

I recommend to unpack the tarball for
example into /usr/local/autonet-[version] and symlink it in /usr/local/sbin or
somewhere else in the path of the root user:

cd /usr/local
tar xvjf /path/to/autonet-[version].tar.bz2
cd autonet-[version]
chmod +x autonet.py
ln -s autonet.py /usr/local/sbin

There are also two init script contained in this package. The one for Debian is called
debian-autonet-init, the one for Gentoo gentoo-autonet-init.


If you want to use the modules for your own python programs, you can add the
installation directory to your $PYTHONPATH environmental variable.

You will also need the following utilities :
   - fping
   - arping



Configuration:
--------------

All Distros
============

Required entries in the configuration file are the lines beginning with: iface,
netmask and gateway.


Debian GNU/Linux:
=================

Place configuration files in the style of the file 'interfaces.example' in
/etc/network. The location of the configurationfiles can be overridden with the
--config-dir flag.

Here's an example, my /etc/init.d/interfaces.home :

-----------------------------------------------
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

# The first network card - this entry was created during the Debian installation
# (network, broadcast and gateway are optional)
auto eth0
iface eth0 inet static
        address 192.168.1.33
        netmask 255.255.0.0
        network 192.168.0.0
        broadcast 192.168.255.255
        gateway 192.168.1.1

----------------------------------------------

Gentoo Linux
=============

The defaults for autonet are written for the debian distribution.
So here are some notes to using autonet with gentoo.

autonet in gentoo works something different to debian.
Here I will mainly describe the use of the init system.

You should edit gentoo.conf to your needs and copy to
/etc/conf.d/autonet.

cp gentoo.conf /etc/conf.d/autonet

The file /etc/conf.d/autonet contains the default
variables for the init script gentoo.init which you
probably want to copy to /etc/init.d/.

cp gentoo.init /etc/init.d/autonet

Then you can test your configuration with the command
/etc/init.d/autonet start
and if you perhaps want to use autonet during the bootup type
rc-update add autonet default

Note: Do not use the arping binary provided by the iputils packages, this one 
does not provide all necessary functions (like pinging from 0.0.0.0). The ebuild 
for simply "arping" should be fine.

Usage:
-------

Please see --help for details on how to use autonet.py.

Usually you want to invoke autonet.py with the -a switch, which starts detection
of the network environment.
If autonet suits your needs, there is a SystemV init style script included in
the package, simply called debian-autonet-init, and a Gentoo-style init script,
called gentoo-autonet-init.



Bugs and contact:
------------------

Please report bugs, comments and featurerequests to

[ sebas [at] vizZzion [dot] org ]


Changelog:
-----------
0.5.0 - 29-03-2004
      - renamed to 0.5.0 after extensive testing, this should be a stable and reliable 
        core
	
0.4.9 - 19-03-2004
  - kraM [ groover [at] streik [dot] no-ip [dot] org ] :
      - minor cleanups in gentoo scripts
      - adaption of new defaults in gentoo scripts
  - sebas [ sebas [at] vizZzion [dot] org ] :
      - fixed fping timeout, major decrease of detection time in some cases
      - added --tmpfile parameter, moved default location of tmpfile from 
        /tmp/autonet-tmp.log to ~/.autonet/log
      - in some cases where the system environment is not complete, /.autonet has
        been created, fixed by more strict checking on $HOME (must be > 1 letter)
      - updated README.txt
	
0.4.8 - 21-02-2004
  - kraM [ groover [at] streik [dot] no-ip [dot] org ] :
      - added Gentoo documentation
      - added gentoo init script
      - added gentoo.conf
  - sebas [ sebas [at] vizZzion [dot] org ] :
      - changed name of init scripts to debian-autonet-init and gentoo-autonet-init
      - changed default testhost to the IP address of k.root-servers.org, I believe
        this to be a sane choice as reference host.
      - fixed autonet.py to override also locations of fping and arping when using
        --distro gentoo
      - tightened import statements
      - other minor cleanups
      - updated api-docs/
      - updated README.txt

0.4.7 - 20-02-2004
  - fixed bug with changing the locations of ping, fping, arping, ifconfig, and
    the timeout
  - fixed debugging not showing the fping location correctly
  - Thanks to kraM [ groover [at] streik [dot] no-ip [dot] org ] for testing :)
  - changed name of the init script to 'autonet-init'

0.4.6 - 25-12-2003
  - added pidfile functionality, when autonet is started, a pidfile is written
    (usually /var/run/autonet.pid) and removed after probing, if this pidfile
	already exists when autonet is invoked, it will exit 1
	added parameter --remove-pid (which obviously removes the pidfile).

0.4.5 - 12-12-2003
  - added condigdirectory ~/.autonet/last_good_config to cache the last success-
    fulley probed configuration and use it first, override with --ignore-last
  - updated documentation

0.4.4 - 10-12-2003
  - fixed minor bugs
  - autonet now first checks if there is already a working connection, and quits
    cleanly in this case, *new default*
  - added --probe-anyway which prevents the above behaviour
  - thx to kraM [ groover [at] streik [dot] no-ip [dot] org ] for testing :)


Known Bugs:
------------
- [FIXED] last_good_config seems to get written anyways, even if no network connections  
  could be established [fixed in 0.4.6]
- [FIXED] releasecritial bug: in some cases autonet will wait until a ping reply is 
  received, this will make autonet take much longer (80 sec / 2 configs). fping is 
  invoked with timeout. [fixed in 0.4.9] 

  
Todo:
------
- restore network settings after unsuccessful probing
- run scripts according to result of probe (e.g. for setting DNS, firewall, etc.) 
- support for wireless devices (Anyone willing to donate an Access Point? ;-) )
  

/*
 *  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 Library 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 the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
  
  
(README.txt)




30-03-2004, 03:05 h
© Sebastian Kügler
[Parsetime: 0.2046sec]