man divine (Commandes) - guess the current networking setup

NAME

divine - guess the current networking setup

SYNOPSIS

divine [eth0]

DESCRIPTION

Divine is meant for mobile setups, where the same machine is carried around and used in more than one network, but you have fixed IP addresses in all those networks. Many people use IP aliases or write crude shell scripts to switch the IP setup manually, but a better solution would be to specify your IP number in every network and a few other IP numbers and then run a program that simply checks all the given IP numbers and sees which answers. This way you can reliably find out in which network you actually are and thus set the networking options accordingly.

If no arp replies are found, divine will re-send the ARP queries. This is useful for laptops with 10/100 MBit Ethernet cards that need some time to negotiate the speed. There are 3 retries before divine gives up and leaves the network setup as-is. I used POSIX threads to implement this.

Divine can also run a user-specified script dependant on the network setup found, so you can also change /etc/issue or somehow set the default printer or do whatever you want.

OPTIONS

[eth0]
You can optionally specify the network interface to use. If none is given, divine chooses the first non-loopback device it finds.

INSTALLATION

divine is normally installed in /etc/pcmcia/network.opts in start_fn. I use

start_fn () { /usr/sbin/divine; return; }

BUGS

The network interface should be determined at run time. libnet has a function for this but I was too lazy. Maybe some *BSD user will contribute a fix for this.

Do NOT make divine setuid root!

Divine executes commands, and the script you specified could probably be exploited to get a shell by an attacker.

Divine passes the comment from /etc/divine.conf to the shell script you specify there, too. No attempt is made to escape shell meta characters, so the most obvious one to avoid is '"'.

SEE ALSO

AUTHOR

Felix 'Fefe' von Leitner <felix@fefe.de>