Plan 9的Manual和Wiki上面关于网络配置的介绍,都是以server为原型,前提条件是这些server都会有固定的IP地址,集成DHCP、DNS乃至自己的子网。可我的Plan 9是在VirtualBox4.0的虚拟机上装的,Host是Fedora 14,通过家用无线路由器上网,IP地址动态获取,不可能有固定IP和固定的DNS、Gateway等等。因此http://cm.bell-labs.com/wiki/plan9/Network_configuration/index.htmlhttp://plan9.escet.urjc.es/magic/man2html/8/ipconfig的方法根本无效。

VirtualBox4.0安装Plan9时,由于没有选择正确的网卡,Plan9使用了默认的Am79C970A网卡,而Plan 9自身并没有该网卡的驱动。要使用plan9自带的网卡驱动而无须自己编译内核的方法就是在plan9.ini中更改默认网卡的类型,可以参考 http://plan9.escet.urjc.es/magic/man2html/8/plan9.ini。plan9.ini存储在9fat中,默认不挂载到fossil,因此需要在Rio的窗口中输入命令“9fat:”挂载9fat,然后cd /n/9fat/,编辑plan9.ini,加入一行“ether0=type=igbe”。同时VirtualBox的网卡也要选择NAT --> Intel Pro1000系列。重启Plan9之后,可以通过ip/ipconfig检查网卡是否能正常工作——如果不报错,证明网卡正常。

网卡正常工作后,我曾经尝试使用下列命令配置网络,DHCP可以正常工作,但DNS一直无法解析域名:

ip/ipconfig -D -d ether /net/ether0

 

尝试更改/lib/ndb/local多次,仍然无效。无奈之下打开/rc/bin/termrc,发现其中依然有了网络配置的内容,只是默认被注释掉了,去掉if以及ip/ipconfig两行前面的#后,重启Plan 9,网络竟然正常了!

# start IP on the LAN, if not already configured.  diskless terminals
# are already configured by now.  It's commented out to avoid a long timeout
# on startup waiting for DHCP.
#
# If your site provides DHCP service,
#
#if(! test -e /net/ipifc/0/ctl)
#	ip/ipconfig
#
# Otherwise, see /cfg/$sysname/termrc (/cfg/example/termrc is an example).

 

 

另外,9vx本身没有虚拟网卡,因此在/net下没有ether0的选项;但是9vx默认是通过宿主机的网卡来上网的,因此一般情况下9vx的网络无须特殊配置(/rc/bin/termrc中也有对vx32的相应处理)。