Reference

guessnet(1)

guess the current network location using fake ARP requests.

NAME

guessnet - guess the current network location using fake ARP requests.

SYNOPSIS

guessnet [options] [ethernet_interface] [config_file]

DESCRIPTION

Guessnet is a program to guess the current network location using fake ARP packets. The program expects a list of network data, that can be read from config_file or from standard input, and prints a tag identifying the network it finds connected to the specified ethernet_interface on standard output. Every line of network data describes a network candidate and its relative tag. A default tag is printed if no candidate is detected, and can be specified with the -d or --default commandline options.

The program decides that no networks are found after some seconds passed without receiving suitable ARP replies. The timeout can be changed with the -t or --timeout commandline option. Some hardware needs longer timeouts to compensate for long initialization times of the network card.

If ethernet_interface is omitted, `eth0' is assumed.

OPTIONS

These programs follow the usual GNU command line syntax, with long options starting with two dashes (`-').

-d, --default=STRING

Tag to print if no known networks are found. Defaults to ethernet_interface-none.

-t, --timeout=INT

Timeout in seconds used to wait for response packets (defaults to 3).

--init-time=INT

Time (in seconds) to wait for the interface to initialize when it is not found already up at program startup (defaults to 3 seconds)

-v, --verbose

Operate verbosely.

-V, --very-verbose

Operate more verbosely, for debugging purposes.

--version

Show version of program.

--usage

Show a brief usage message.

-?, --help

Show summary of options.

NETWORK DATA FORMAT

The network data looks like this:

# Empty lines and comment lines starting with '#'
# are ignored.
# Home network
192.168.1.2 00:01:02:03:04:05 192.168.1.1 home
# University
130.136.3.42 05:06:03:02:01:0A 130.136.1.1 university
130.136.3.42 15:13:B3:A2:2F:CD 130.136.1.2 university
# Work
10.1.1.42 0A:0B:0C:0D:0E:0F 10.1.1.1 work
10.1.1.42 0F:0E:0D:0C:0B:0A 10.1.1.2 work

A network data line identifies a candidate network to test and contains 4 fields:

Local IP

Indicates the IP to use as a source IP address for ARP requests. At the moment I lack documentation about the ARP protocol, but I would like to remove the need to specify this field. It should, however, be a valid (and probably unused) IP address inside the network we are testing.

Remote MAC

Indicates a MAC address for a host we know is present in this network. You can find macaddresses of other computers in the network using the command 'arp -v'; see man arp(8) for more details.

Remote IP

Indicates the IP address corresponding to the MAC address given.

Network name

Name to be printed on standard output if this network is found.

NOTES

Here follow some notes to give suggestions and examples on guessnet usage.

/etc/network/interfaces integration

guessnet gets interesting if combined with the standard debian ifupdown scripts, to automatically guess what data to use to configure the interface.

Here's an example of an interfaces file using guessnet:

auto lo eth0
iface lo inet loopback
mapping eth0
	# Too bad there's no way to pass commandline options to script
	script /usr/bin/guessnet
	# Test for my other home PC
	map 192.168.1.2 00:01:02:03:04:05 192.168.1.1 eth0-home
	# Test for the gateway we have at work
	map 10.1.1.42 00:0A:0B:0C:0D:0E 10.1.1.1 eth0-work
# Home network configuration
iface eth0-home inet static
	address 192.168.1.2
	netmask 255.255.255.0
	broadcast 192.168.1.255
	gateway 192.168.1.1
	up ln -fs /etc/roaming/resolv.conf_home /etc/resolv.conf
	up echo "smarthost: main.home" > /etc/roaming/exim_options
	up rm -f /etc/roaming/not_online
# Work network configuration
iface eth0-work inet static
	address 10.1.1.42
	netmask 255.255.255.0
	broadcast 10.1.1.255
	gateway 10.1.1.1
	up ln -fs /etc/roaming/resolv.conf_work /etc/resolv.conf
	up echo "smarthost: mail.work.it" > /etc/roaming/exim_options
	up rm -f /etc/roaming/not_online
# eth0 defaults (too bad there's no 'disabled' method for iface...)
iface eth0-none inet static
	address 192.168.1.2
	netmask 255.255.255.0
	up ln -fs /etc/roaming/resolv.conf_none /etc/resolv.conf
	up touch /etc/roaming/not_online

Getting remote host macaddresses

When you prepare the input data to guessnet you may need to know the MACaddress of a remote interface in the local network. There are many ways to do this: the easier is by using the arping utility by issuing "arping [hostname]". If you haven't arping installed in your system, issue the command "arp -a [hostname]" to display the MAC address taking the information from the ARP cache of your machine. You might want to ping the remote interface first to be sure to have the informations in the cache.

SEE ALSO

ifup(8), interfaces(5), arping(8).

AUTHOR

guessnet has been written by Enrico Zini <[email protected]>, taking the ARP network detection code from laptop-netconf by Matt Kern <[email protected]>, based in turn on divine by Felix von Leitner <[email protected]>.