Date: Wed, 22 Mar 2000 14:17:03 +0000 From: Brian Somers <brian@Awfulhak.org> To: Lars Eggert <larse@isi.edu> Cc: freebsd-mobile@FreeBSD.org, brian@hak.lan.Awfulhak.org Subject: Re: switching between connected/disconnected operation? Message-ID: <200003221417.OAA02725@hak.lan.Awfulhak.org> In-Reply-To: Message from Lars Eggert <larse@isi.edu> of "Tue, 21 Mar 2000 18:40:54 GMT." <14551.49718.603919.823550@hbo.isi.edu>
next in thread | previous in thread | raw e-mail | index | archive | help
> Hi, > > we're trying to come up with a way to configure our laptops so that we > can easily switch between connected (i.e. we have a net) and > disconnected (we have no net) states. This does not need to be > automatic (would be nice though), having users type "net on|off" in a > shell is perfectly fine. > > Looking at /etc, it seems that what we'd like requires non-trivial > changes to the configuration; the laptops we'd like this for run a > number of services that would need to be started/stopped: NIS, NFS > (clients), inetd, sendmail, sshd, lpd, amd, named, etc. Some of these > should be okay to leave running when disconnecting (e.g. inetd, sshd). > Others (NIS, NFS, amd) must be stopped/restarted. > > Has anyone ever done this? How? Any pointers? This is for 4.0-RELEASE, > btw. > > Thanks, > Lars > > PS: I'm not currently subscribed, please cc me explicitly. > ________________________________________________________________________ > Lars Eggert <larse@isi.edu> Information Sciences Institute > http://www.isi.edu/~larse/ University of Southern California I use this script - called from /etc/pccard.conf (see below). This is a hack that's grown over the years but is now based entirely on dhcp. I've toyed with developing it into some sort of /etc/defaults/ type setup, and although it's a bit of a hack, I think the basic idea is reasonably sound -- keep ``configfile''.``profile'', and then have a setup script that symlinks ``configfile'' to these. #! /bin/sh if [ $(id -u) -ne 0 ] then echo "You've gotta be root" >&2 exit 1 fi case "$1" in *[0-9]) iface=$1 shift;; *) iface=ep0;; esac if ! ifconfig $iface >/dev/null 2>&1 then echo Plug the network card in first >&2 exit 1 fi homeip=172.16.0.12 homemask=0xffffff00 homebits=24 homedefault=172.16.0.1 homeresolv="search lan.Awfulhak.org vm.Awfulhak.org" #dbip=10.128.148.206 # dblon01ra1.wks.uk.deuba.com dbip=10.128.* dbmask=0xffffff00 dbbits=24 dbdefault=10.128.148.250 dbresolv="search lan.Awfulhak.org vm.Awfulhak.org wks.uk.deuba.com mkdc srv.uk.deuba.com" #dbip=10.141.32.137 #dblon01ra1 #dbip=10.141.32.176 #unknown1835 #dbmask=0xfffffc00 #dbbits=22 #dbdefault=10.141.35.250 dpdip=10.10.10.22 dpdmask=0xffffff00 dpdbits=24 dpddefault=10.10.10.1 dpdresolv="search lan.Awfulhak.org vm.Awfulhak.org" hostname=`hostname -s` if [ $# -eq 0 ] then #ifconfig $iface inet $homeip netmask $homemask #ping -c1 $homedefault && exec $0 home #ifconfig $iface inet $dbip netmask $dbmask #ping -c1 $dbdefault && exec $0 db #ifconfig $iface inet $dpdip netmask $dpdmask #ping -c1 $dpddefault && exec $0 dpd #logger -s "Dunno where I am, default to dhclient !" killall dhclient if ! /sbin/dhclient $iface then logger -s "Network not configured - dhclient failed $?" exit 1 fi ip=`ifconfig $iface | sed -n 's/.*inet \([^ ]*\) .*/\1/p'` rm -f /usr/local/etc/proxy.cfg case "$ip" in $dbip) set -- db router=`netstat -rn | fgrep default | awk '{print $2;}'` route add 10.0/8 $router route add 192.168.0.0/16 $router route delete default rdate oasysdev1 /usr/local/bin/tcpchat oasysdev2 666 "" "hak $ip" { echo export FTP_PROXY=10.141.253.147:8080 echo export HTTP_PROXY=10.141.253.147:8080 echo export ftp_proxy=ftp://10.141.253.147:8080/ echo export http_proxy=http://10.141.253.147:8080/ # Known proxies: # 10.141.253.146:8080 # 10.141.253.147:8080 # 10.140.201.33:8080 # 10.140.201.34:8080 } >/usr/local/etc/proxy.cfg ;; $homeip) set -- home rdate gate { echo export FTP_PROXY=172.16.0.1:3128 echo export HTTP_PROXY=172.16.0.1:3128 echo export ftp_proxy=ftp://172.16.0.1:3128/ echo export http_proxy=http://172.16.0.1:3128/ } >/usr/local/etc/proxy.cfg;; $dpdip) set -- dpd;; *) exit 0;; esac elif [ ."$1" = .home -o ."$1" = .homedb ] then ip=$homeip mask=$homemask bits=$homebits default=$homedefault rwhod=-p #ns1=127.0.0.1 #ns2=172.16.0.1 #ns3=172.16.0.5 elif [ ."$1" = .db ] then ip=$dbip mask=$dbmask bits=$dbbits default=$dbdefault rwhod=-l #ns1=10.141.32.84 # Mark #ns2=10.140.12.10 # sp2icws.mkdc #ns3=10.140.12.11 # sp01-e0.mkdc # HTTP_PROXY=interproxy.srv.uk.deuba.com:80 elif [ ."$1" = .dpd ] then ip=$dpdip mask=$dpdmask bits=$dpdbits default=$dpddefault rwhod=-p else echo "Home or db ?" >&2 exit 1 fi if [ -n "$default" ] then ifconfig $iface inet $ip netmask $mask route delete default >/dev/null 2>&1 route -n flush >/dev/null 2>&1 route add default $default fi echo -n Starting eval echo \$${1}resolv >/etc/resolv.conf echo nameserver 127.0.0.1 >>/etc/resolv.conf ln -fs inetd.conf.$1 /etc/inetd.conf ln -fs named.conf.$1 /etc/namedb/named.conf ln -fs smb.conf.$1 /usr/local/etc/smb.conf ln -fs socks5.conf.$1 /usr/local/etc/socks5.conf ln -fs printcap.$1 /etc/printcap ln -fs $hostname.$1.cf /etc/mail/sendmail.cf ln -fs hosts.allow.$1 /etc/hosts.allow killall smbd nmbd socks5 rwhod named sendmail inetd httpd 2>/dev/null . /etc/defaults/rc.conf /usr/sbin/inetd $inetd_flags /usr/sbin/sendmail $sendmail_flags ${named_program:-/usr/sbin/named} $named_flags /usr/local/bin/socks5 /usr/sbin/rwhod $rwhod test -s /usr/local/arpwatch/arp.dat || cp /usr/local/arpwatch/arp.dat- /usr/local/arpwatch/arp.dat /usr/local/sbin/arpwatch -i $iface && echo -n ' arpwatch' #test $1 = home && /usr/sbin/timed -M test $1 = home && su -l news >/dev/null 2>&1 & /usr/local/etc/rc.d/samba.sh echo logger -s "Network configured for $1" -- Brian <brian@Awfulhak.org> <brian@[uk.]FreeBSD.org> <http://www.Awfulhak.org> <brian@[uk.]OpenBSD.org> Don't _EVER_ lose your sense of humour ! To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-mobile" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200003221417.OAA02725>