From mboxrd@z Thu Jan 1 00:00:00 1970 From: tad@plan9.bell-labs.com Message-Id: <200006190641.CAA14768@cse.psu.edu> Subject: [9fans] Roaming Plan9 terminal (laptop) network configuration Date: Mon, 19 Jun 2000 02:41:14 -0400 To: 9fans@cse.psu.edu MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: c3b62a76-eac8-11e9-9e20-41e7f4b1d025 I just threw the attached little script together to make network configuration easy for any number of roaming ethernet (non-dhcp and dhcp) configurations. 1) edit /rc/bin/termrc, comment out the 'ip/ipconfig' line, and replace it with an invocation of '/rc/bin/netconfig'. 2) netconfig will prompt you to enter a system name, If you just hit return, it will default to DHCP. the system name you enter must exist in your ndb database (/lib/ndb/local, probably) looking something like this: ipnet=home-net ip=192.168.100.0 ipmask=255.255.255.0 dnsdomain=cs.bell-labs.com dnsdomain=research.bell-labs.com dns=135.1.1.150 ipgw=192.168.100.105 dns=135.1.1.150 # # ipgw and ipmask set here so /rc/bin/netconfig can # find them. (I don't currently know a better way # to get from the sysname to the network record above) # ip=192.168.100.103 sys=think ether=0060973ff2ae ipgw=192.168.100.105 ipmask=255.255.255.0 dom=think.lackawanna.net Note that you don't need the separate 'home-net' entry, you could have put the dnsdomain and dns server entries in the 'sys=think' entry. --------------- /rc/bin/netconfig ------------------ #!/bin/rc fn run { echo $* eval $* } fn try { ip=`{ndb/query sys $1 ip} if(~ $#ip 0) { echo no ip address for $1 echo fail } ipgw=`{ndb/query sys $1 ipgw} if(~ $#ipgw 0) { echo warning: no ip gateway for $1 >[1=2] gw='' } if not gw='-g'$ipgw ipmask=`{ndb/query sys $1 ipmask} if(~ $#ipmask 0) { echo no ip mask for $1 >[1=2] echo fail } run ip/ipconfig $gw ether /net/ether0 add $ip $ipmask >[1=2] echo ok } while() { echo -n 'system name [dhcp]: ' x=`{read} if(~ $#x 0) { echo ip/ipconfig -dD exit } ok=`{try $x} if(~ $ok ok) exit }