Index of /~khorben/projects/netbsd/usr/sbin

      Name                    Size  Description

[DIR] Parent Directory - [TXT] ifcarrier 1k

NetBSD super-user programs by khorben

NetBSD super-user programs by khorben

Contents


ifcarrier

ifcarrier is a script meant to automatically detect and apply the relevant network settings on a NetBSD system, each time a wired connection cuts in and out.

Description

The technique used consists of querying the MAC address of potentially known machines on the network, and comparing them with the expected result from a local database.

This is done here on NetBSD, with the help of the ifwatchd daemon.

Installation

To install ifcarrier onto your system, please follow these steps:

  1. in the instructions, replace if0 by the name of the interface you want to setup;
  2. download and copy ifcarrier into your /usr/local/sbin folder (make sure it is executable and belongs to root);
  3. create a /etc/ifcarrier.if0 file this way, with one entry per line:
    gw_mac_address	gw_ip		your_ip		network_name
    
    where gw_ip is the IP of any other machine always found on the given network, gw_mac_address is its MAC address, and your_ip is your usual IP on the network
  4. for each network listed, create a /etc/ifconfig.if0.network_name containing the desired settings for the corresponding network;
  5. modify the initial /etc/ifconfig.if0 file to just initialize the interface, typically simply containing this line:
    up
  6. activate ifwatchd by default for if0 by appending this to /etc/rc.conf:
    ifwatchd=YES
    ifwatchd_flags="-c /usr/local/sbin/ifcarrier if0"
  7. finally, start the ifwatchd daemon:
    /etc/rc.d/ifwatchd start

How to debug

As always, consult your logs and particularly /var/log/messages, which should tell you this when you plug in your cable:

/usr/sbin/ifwatchd: watching interface if0
/usr/sbin/ifwatchd: calling: /usr/local/sbin/ifcarrier if0 /dev/null 9600

You can also track the state of your interface with the ifconfig if0 command.

Known issues