May 29 2008

Solaris 下的网卡驱动和网络配置

Category: 技术ssmax @ 15:06:41

本文在solaris下面写的,最新版,自带的拼音输入法还不错,很流畅。。。

昨天安装了solaris,但是网卡驱动找不到,去网上找了一下,发现solaris支持的网卡还是很少的,机上的集成网卡芯片是 Realtek RTL8168/8111 ,好像是比较普遍的网卡了,但是Solaris就是没有自带驱动,在网上找到一个人写的驱动,说是支持 Realtek RTL8169/8110的,也支持8168,下载,u盘,copy。。。

按步骤一步步来。。。

# gunzip -cd gani-x.x.x.tar.gz | tar xf –

% cd /…/gani-x.x.x
% rm obj Makefile
% ln -s Makefile.${KARCH}_${COMPILER} Makefile
% ln -s ${KARCH} obj

isainfo看体系,应该是amd64了。。

# cd /…/gani-x.x.x
# /usr/ccs/bin/make install
# ./adddrv.sh
# /usr/ccs/bin/make uninstall (for solaris7, don’t remove the file )
# modload obj/gani
# devfsadm -i gani (for solaris7, use drvconfig and reboot with -r )
# ifconfig ganiN plumb ( where N is an instance number, typcally 0 for first card)
# ifconfig -a ( you will see an entry for ganiN)
# ifconfig ganiN YOUR-HOST-NAME
# ifconfig ganiN ( ensure IP address is correct)
# ifconfig ganiN up ( and then you can test with ping, telnet, ftp …)

做到devfsadm -i gani的时候死活也装不上,这个命令是把驱动绑定设备上面并且生成/dev/gani的,出错:

devfsadm: driver failed to attach: gani

改一下设备名称啦之类的都不行,一直在研究,后来找到网上说solaris新版已经带8169的驱动了,是/kernel/drv/amd64/rge模块,好,试一下能不能强行装上用用。。。

先用prtconf -v | less 找到设备pci地址,网卡设备名一般是Ethernet controller,搜索Ethernet,找到设备地址

pci1458,e000,或者用别名pci10ec,8168都应该可以的,然后强行装上驱动

/usr/sbin/add_drv -n -v -m ‘* 0600 root sys’ -i “pci1458,e000” rge

没出问题

modload /kernel/drv/amd64/rge

devfsadm -i rge

竟然没有出问题,装上了,有个设备rge0了

然后

touch /etc/hostname.rge0

touch /etc/dhcp.rge0

配置成dhcp模式,

dhcp会自动配置

/etc/resolv.conf        dns服务器

/etc/nsswitch.conf    域名解释顺序

等一堆东西。。。然后reboot之。。

开机了,拿到ip地址,dns地址,以为没有问题了,谁知道ping一下网关,没有反应,全部包都丢失,再重启一下看看,正常了,但是解释不了dns。。。只有ping可以通,其他所有服务都用不了,直接ip访问页面也不行,出绝招,

sys-unconfig

重新设定系统的所有配置,oh shit,更惨,连ip都拿不到了,估计还是驱动问题,汗阿汗。。。

死死地气去问it借了个3com的网卡来。。。插上,开机,认出来了,

pci10b7,9055,3Com 3C905B-TX

驱动是elxl,设备号是elxl0。。。

配置好hostname和dhcp,reboot拿到ip,能ping通,能nslookup,但是ping域名或者用firefox上的时候还是不行,unknown hosts错误,tnnd,又检查了半天,觉得可能是nscd服务没有开,这个是name service cache daemon,做dns缓存的,把服务打开,ok了,tnnd。。。

总结一下,

主要的启动日志在/var/adm/message,很多时候要看。

solaris里面的ifconfig比较怪异,基本还是和linux差不多的

tar也比较怪异,没有z项,不能直接tar压缩文件

ps 也很怪异,暂时没有研究它的选项,反正默认显示不了多少东西。。。

route更怪异,没有打印路由的功能,要netstat -nr

最后就是服务管理了,可以直接用unix的常用方法,直接搞/etc/rcx.d/

也有自己提供的方法 svcs 来观察服务是否启动

svcs -v

这套东西是它自己的smf,Solaris Service Management Facility

  • Enabling and disabling servicesPrior to Solaris 10, there wasn’t a good way to permanently disable a service in Solaris. The typical method used is to rename the relevant rc script to a name that won’t get executed, but that change will get overlooked the next time the system is upgraded. Furthermore, inetd-based services are enabled and disabled by a totally different method — editing a configuration file. Under SMF, both types of services can be configured using the svcadm(1M) command, and the changes will persist if the machine is upgraded. Here’s a comparison of how to enable and disable some services:
    Old method
    SMF Method
    mv /etc/rc2.d/S75cron /etc/rc2.d/x.S75cron
    svcadm disable system/cron:default
    edit /etc/inet/inetd.conf, uncomment the finger line
    svcadm enable network/finger:default

    The last argument to svcadm in these examples is the FMRI of the service.

    Note that svcadm should only be used for SMF services — legacy rc script-controlled services work the same as in past releases.

  • Stopping, starting, and restarting servicesTraditionally, services have been started by an rc script run at boot, run with the argument start. Some rc scripts provide a stop option, and a few also allow restart. In SMF, these tasks are all accomplished with the svcadm(1M) command:
    Old method
    SMF Method
    /etc/init.d/sshd stop
    svcadm disable -t network/ssh:default
    /etc/init.d/sshd start
    svcadm enable -t network/ssh:default
    /etc/init.d/sshd stop; /etc/init.d/sshd start
    svcadm restart network/ssh:default
    kill -HUP `cat /var/run/sshd.pid`
    svcadm refresh network/ssh:default

    The “-t” option to svcadm enable and svcadm disable indicates that the requested action should be temporary — it will not affect whether the service is started the next time that the system boots.

不过solaris的错误跟踪是比较强大,比如

truss ping www.163.com

出来一堆跟踪信息。。。

明天还要看dtrace,这个才是这次主要研究对象。。。tnnd郁闷阿。。。