This document describes how to run Kismet server automatically when PCMCIA wireless card inserted. Also I describe how to start gpsd when connecting GPS to USB port. I run SuSE 9.1 in my laptop but hotplug configuration is similar in other distributions. At least I hope you get some ideas here how to do that. My solution may look a little bit ugly hack. It has one very siple reason - I want to keep system files untouched and I created/edited only config files. This makes any system upgrade much easier in the future.
In SuSE system all network configuration files are in /etc/sysconfig/network directory. I have onboard ethernet card which is eth0 and PCMCIA card gets name eth1. The easiest way to configure eth1 automatically is to create file ifcfg-eth1. It is possible to include MAC address in file name also in case you need to use some other card without running Kismet server or running it with some other config. I have built in Intel PRO/Wireless 2100 Network Connection mini PCI adapter in my laptop and don't need PCMCIA wireless for networking.
Configuration file normally consists different networking parameters. It is actually shell script where necessary variables are defined. because it is shell code you can actually include anything into it. Here is how my Kismet startup script in ifcfg-eth1 looks like
STARTMODE=manual
if ifconfig eth1 2>&1 > /dev/null
then
ifconfig eth1 txqueuelen 0 down
ip6tables -A OUTPUT -o eth1 -j DROP
cd /home/wardrive/data
/usr/local/bin/kismet_server --silent 2>&1 >> /dev/null &
else
killall kismet_server 2>&1 > /dev/null
fi
The important line is STARTMODE=manual. This means that system doesn't try to set up anything during boot time and leave network device as is.
ifconfig is used here to check is it card insertion or removal because in both cases this config file is executed.
If inerface exist then it means that card was just inserted. In this case I set interface txqueuelen to zero to prevent any queueing of packets to this interface. It might be not necessary and I'm not sure can it help you or not. Anyway, it doesn't matter if you do it. It is very important to block any IPv6 traffic if you have IPv6 configured because your system tries to do IPv6 autoconfig when interface comes up. This means sending out some IPv6 packets and this must not happen in monitor mode. The easiest way is to use iptables to filter these packets out. You can also disable kernel autoconfig but I found that /proc/sys/net/ipv6/conf/eth1/autoconf was missing in this time. Probably it takes some time when this sysconfig variable appears. Anyway, after that everything is easy already. Just go to the right directory (if you don't have directory name configured for logifiles) and run the server.
I also included server stopping part but this is not very important as Kismet server dies anyway when you remove your PCMCIA card from your laptop (I hope you have a laptop, haven't you?).
If you have GPS with USB port then you have to start gpsd every time after you connect your GPS. I'd like to make such things happen automatically. For that I modified /etc/hotplug/tty.agent to start gpsd when GPS connected and stop in case of disconnection. I stop gpsd every time when tty.agent executed to be sure that there is no daemon already started. If device connected I start gpsd after call_udev has set up device.
here you can see the modified /etc/hotplug/tty.agent
WARNING! SVN versions up to 1161 are buggy and leak file descriptors if gpsd is not running and Kismet tries to reconnect. You can find a patch from Kismet mailing list
NOTICE! kismet-newcore from SVN doesn't have this problem. gpsd should be started before kismet but you can insert/remove USB GPS receiver after that without any problems.