I carry around my old Vaio and connect it to
different subnets. Typing the same commands
(ifconfig ....; route delete default;
route add default ...; cp /etc/resolv.conf.place /etc/resolv.conf;
...)
every time I reconnected got boring, so the stuff
went into scripts. I later heard of Felix von Leitner's
divine.
It sends out fake ARP requests to divine to which
network the machine is connected, and takes configured
actions depending on the results.
It turns out
that it's pretty easy to re-implement this with
“standard&ddquo; utilities on OpenBSD. I use
arping by Thomas Habets from the ports-tree
and
ifstated supplied in the OpenBSD source tree.
ifstated is not installed in the standard
build process, but a simple
cd /usr/src/usr.sbin/ifstated
make && make install
fixes that. The documentation for the config-file
ifstated.conf is non-existant, but an
example is in /usr/src/etc/ifstated.conf.
You can take my
minimal config
for multiple networks and adapt it by substituting
the name of your interface, the IP/MACs of the hosts
in your networks. Works fine in my setup.