Chinaunix首页 | 论坛 | 博客
  • 博客访问: 545006
  • 博文数量: 114
  • 博客积分: 5611
  • 博客等级: 大校
  • 技术积分: 1027
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-19 08:55
文章分类

全部博文(114)

文章存档

2011年(29)

2010年(20)

2009年(1)

2008年(11)

2007年(53)

分类: LINUX

2007-11-23 16:42:37

一般来说,目前新版的 Linux 预设可以支持的网络卡芯片组数量已经很完备了,很多网络卡芯片都已经被支持, UVuLinux联盟
UVuLinux联盟
  例如RLT 8139 芯片 ( RealTek 8139 ) 的网络卡所以使用者可以很轻易的设定好他们的网络卡。 UVuLinux联盟
UVuLinux联盟
  不过,如果万一不幸核心没有支持该网络卡的话,那么可以透过重新编译核心或者编译网络卡驱动模块 ( Modules ), UVuLinux联盟
UVuLinux联盟
  并且加载该模块,今天就是这么巧,碰到一个D-Link 的DFE-530TX,没法,只有手动安装网络卡驱动程序了. UVuLinux联盟
UVuLinux联盟
  可以用命令# dmesg | grep eth UVuLinux联盟
UVuLinux联盟
  来查看系统启动信息,显示出 eth0 或者 eth1 的信息,如果eth1没找到正确的信息,那就表示 Linux 无法找到该硬件, UVuLinux联盟
UVuLinux联盟
  eth0是8139的,已经显示正常,例如: UVuLinux联盟
UVuLinux联盟
[root@kindgeorge root]# dmesg | grep eth UVuLinux联盟
UVuLinux联盟
eth0: RealTek RTL8139 Fast Ethernet at 0xf0160000, 00:0a:a6:30:0d:0e, IRQ 11 UVuLinux联盟
UVuLinux联盟
eth0: Identified 8139 chip type 'RTL-8139C' UVuLinux联盟
UVuLinux联盟
eth0: Setting 10mbps full-duplex based on auto-negotiated partner ability 4061. UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
一. 查看自己系统的内核版本. UVuLinux联盟
UVuLinux联盟
[root@kindgeorge root]# uname -r UVuLinux联盟
UVuLinux联盟
2.4.18-3  UVuLinux联盟
UVuLinux联盟
我这里是redhat7.3的,内核2.4.18-3 UVuLinux联盟
UVuLinux联盟
一般来说,这个内核驱动程序的模块会放在 /lib/modules/2.4.18-3/kernel/drivers/net UVuLinux联盟
UVuLinux联盟
二.确定系统是否已经安装下面包 UVuLinux联盟
UVuLinux联盟
1.由于编译需要用到内核的源代码包和编译程序gcc.所以如果没有的话,要先装. UVuLinux联盟
UVuLinux联盟
查看: UVuLinux联盟
UVuLinux联盟
[root@kindgeorge root]# rpm -qa|grep kernel UVuLinux联盟
UVuLinux联盟
kernel-2.4.18-3 UVuLinux联盟
UVuLinux联盟
kernel-source-2.4.18-3 UVuLinux联盟
UVuLinux联盟
[root@kindgeorge root]# rpm -qa|grep gcc (gcc是编译用) UVuLinux联盟
UVuLinux联盟
gcc-2.96-110 UVuLinux联盟
UVuLinux联盟
gcc-g77-2.96-110 UVuLinux联盟
UVuLinux联盟
gcc-c++-2.96-110 UVuLinux联盟
UVuLinux联盟
一般装了内核源包的话,都会在出现/usr/src/linux-2.4,同路径下会有linux-2.4.18-3的文件实际目录. UVuLinux联盟
UVuLinux联盟
2.如果没有的话,就用原来安装盘上的文件安装,会去下载个相同内核源包安装吧 UVuLinux联盟
UVuLinux联盟
rpm -ivh kernel-source-2.4.18-3.i386.rpm UVuLinux联盟
UVuLinux联盟
...... UVuLinux联盟
UVuLinux联盟
三. 取得驱动程序和编译 UVuLinux联盟
UVuLinux联盟
1. 可以重厂家提供的光盘提供,把光盘上的linux目录下的dlkfet-4.24.tar.gz 拷贝过来用. UVuLinux联盟
UVuLinux联盟
2. 从网上下载网络卡驱动程序,一般厂家的网站都提供下载程序的. UVuLinux联盟
UVuLinux联盟
例如: 上有下载. UVuLinux联盟
UVuLinux联盟
[root@kindgeorge root]# cp dlkfet-4.24.tar.gz /usr/src UVuLinux联盟
UVuLinux联盟
[root@kindgeorge root]# cd /usr/src/ UVuLinux联盟
UVuLinux联盟
[root@kindgeorge src]# tar -zxvf dlkfet-4.24.tar.gz UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/ UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine_main.c UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/Makefile UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/vmns_drv.h UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine.h UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/.depend.mak UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine_vmns.c UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine_proc.h UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine_proc.c UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine_vmns.h UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/kcompat.h UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine_cfg.h UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/.depend UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine_wol.c UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/rhine_wol.h UVuLinux联盟
UVuLinux联盟
dlkfet-4.24/linux.txt UVuLinux联盟
UVuLinux联盟
3.请留意一开始是没有.o文件的. 我们编译前可以看看目录的linux.txt,是一个包含介绍安装说明.在进入目录后,执行make进行编译. UVuLinux联盟
UVuLinux联盟
[root@kindgeorge src]# cd dlkfet-4.24 UVuLinux联盟
UVuLinux联盟
[root@kindgeorge dlkfet-4.24]# make UVuLinux联盟
UVuLinux联盟
[root@kindgeorge dlkfet-4.24]# ll (编译后查看一下) UVuLinux联盟
UVuLinux联盟
total 320 UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 7473 Jan 15 2003 kcompat.h UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 11491 Jan 20 2003 linux.txt UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 5219 Dec 10 2002 Makefile UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 1818 Jan 16 2003 rhine_cfg.h UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 48715 May 24 18:31 rhinefet.o UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 42044 Jan 15 2003 rhine.h UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 78996 Jan 16 2003 rhine_main.c UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 32760 May 24 18:31 rhine_main.o UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 14980 Jan 15 2003 rhine_proc.c UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 1672 Jan 15 2003 rhine_proc.h UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 12336 May 24 18:31 rhine_proc.o UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 9172 Jan 15 2003 rhine_vmns.c UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 1106 Jan 15 2003 rhine_vmns.h UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 3792 May 24 18:31 rhine_vmns.o UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 7536 Jan 15 2003 rhine_wol.c UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 1529 Jan 15 2003 rhine_wol.h UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 3488 May 24 18:31 rhine_wol.o UVuLinux联盟
UVuLinux联盟
-rw-r--r-- 1 root root 6824 Jan 15 2003 vmns_drv.h UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
4.经过编译后,会编译出一个rhinefet.o 文件,这个就是驱动模块,我们把它拷贝到相应地方: UVuLinux联盟
UVuLinux联盟
[root@kindgeorge dlkfet-4.24]#cp rhinefet.o /lib/modules/2.4.18-3/kernel/drivers/net UVuLinux联盟
UVuLinux联盟
[root@kindgeorge dlkfet-4.24]# depmod -a UVuLinux联盟
UVuLinux联盟
5.测试 UVuLinux联盟
UVuLinux联盟
(1)可以用命令modprobe rhinefet 或 insmod rhinefet.o 加载.如果没出错信息说明ok. UVuLinux联盟
UVuLinux联盟
(2) 用命令lsmod 可以看看是否已经加载了. UVuLinux联盟
UVuLinux联盟
[root@kindgeorge dlkfet-4.24]# lsmod UVuLinux联盟
UVuLinux联盟
Module Size Used by Not tainted UVuLinux联盟
UVuLinux联盟
rhinefet 38752 1 UVuLinux联盟
UVuLinux联盟
8139too 16448 1 UVuLinux联盟
UVuLinux联盟
mii 2408 0 [8139too] UVuLinux联盟
UVuLinux联盟
这样,看到rhinefet模块已经加载了,基本上,这样就证明已经编译成功. UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
6. 让它开机时加载 UVuLinux联盟
UVuLinux联盟
[root@kindgeorge dlkfet-4.24]# vi /etc/modules.conf UVuLinux联盟
UVuLinux联盟
在后面加上一行: alias eth1 rhinefet UVuLinux联盟
UVuLinux联盟
7. 配置一下网络 UVuLinux联盟
UVuLinux联盟
[root@kindgeorge dlkfet-4.24]# vi /etc/sysconfig/network-scripts/ifcfg-eth1 UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
DEVICE=eth1 UVuLinux联盟
UVuLinux联盟
BOOTPROTO=static UVuLinux联盟
UVuLinux联盟
IPADDR=192.168.4.202 UVuLinux联盟
UVuLinux联盟
NETMASK=255.255.255.0 UVuLinux联盟
UVuLinux联盟
NETWORK=192.168.4.0 UVuLinux联盟
UVuLinux联盟
GATEWAY=192.168.4.250 UVuLinux联盟
UVuLinux联盟
BROADCAST=192.168.4.255 UVuLinux联盟
UVuLinux联盟
ONBOOT=yes UVuLinux联盟
UVuLinux联盟
8.启动网卡,然后用ifconfig查看, UVuLinux联盟
UVuLinux联盟
ifup eth1 UVuLinux联盟
UVuLinux联盟
[root@kindgeorge dlkfet-4.24]# ifconfig UVuLinux联盟
UVuLinux联盟
eth0 Link encap:Ethernet HWaddr 00:0A:E6:30:0D:0E UVuLinux联盟
UVuLinux联盟
inet addr:211.239.218.153 Bcast:211.239.218.255 Mask:255.255.255.0 UVuLinux联盟
UVuLinux联盟
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 UVuLinux联盟
UVuLinux联盟
RX packets:3780479 errors:0 dropped:0 overruns:0 frame:0 UVuLinux联盟
UVuLinux联盟
TX packets:3833860 errors:0 dropped:0 overruns:0 carrier:0 UVuLinux联盟
UVuLinux联盟
collisions:0 txqueuelen:100 UVuLinux联盟
UVuLinux联盟
RX bytes:1118112324 (1066.3 Mb) TX bytes:1111887387 (1060.3 Mb) UVuLinux联盟
UVuLinux联盟
Interrupt:11 UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
eth1 Link encap:Ethernet HWaddr 00:0F:3D:82:EC:1D UVuLinux联盟
UVuLinux联盟
inet addr:192.168.4.202 Bcast:192.168.4.255 Mask:255.255.255.0 UVuLinux联盟
UVuLinux联盟
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 UVuLinux联盟
UVuLinux联盟
RX packets:749312 errors:0 dropped:0 overruns:0 frame:0 UVuLinux联盟
UVuLinux联盟
TX packets:976174 errors:0 dropped:0 overruns:0 carrier:0 UVuLinux联盟
UVuLinux联盟
collisions:0 txqueuelen:100 UVuLinux联盟
UVuLinux联盟
RX bytes:43695059 (41.6 Mb) TX bytes:1472142037 (1403.9 Mb) UVuLinux联盟
UVuLinux联盟
Interrupt:5 Base address:0xe000 UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
9.重新启动机器,可以自动加载和使用了.大功告成. UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
五. 按照安装说明的方法自动编译安装. UVuLinux联盟
UVuLinux联盟
在 "三.3" 中我们用make 编译,然后进行手动的拷贝. 实际上在linux.txt中的安装说明提到用make install . UVuLinux联盟
UVuLinux联盟
那我们来看看这种方法系统都做了什么吧. UVuLinux联盟
UVuLinux联盟
[root@firewall1 dlkfet-4.24]# make install UVuLinux联盟
UVuLinux联盟
gcc -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe -I/lib/modules/2.4.18-3/build/include -I. -Wstrict-prototypes -fomit-frame-pointer -DMODVERSIONS -include /lib/modules/2.4.18-3/build/include/linux/modversions.h -DVMNS -c -o rhine_main.o rhine_main.c UVuLinux联盟
UVuLinux联盟
gcc -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe -I/lib/modules/2.4.18-3/build/include -I. -Wstrict-prototypes -fomit-frame-pointer -DMODVERSIONS -include /lib/modules/2.4.18-3/build/include/linux/modversions.h -DVMNS -c -o rhine_proc.o rhine_proc.c UVuLinux联盟
UVuLinux联盟
gcc -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe -I/lib/modules/2.4.18-3/build/include -I. -Wstrict-prototypes -fomit-frame-pointer -DMODVERSIONS -include /lib/modules/2.4.18-3/build/include/linux/modversions.h -DVMNS -c -o rhine_wol.o rhine_wol.c UVuLinux联盟
UVuLinux联盟
gcc -Wall -DLINUX -D__KERNEL__ -DMODULE -DEXPORT_SYMTAB -D__NO_VERSION__ -O2 -pipe -I/lib/modules/2.4.18-3/build/include -I. -Wstrict-prototypes -fomit-frame-pointer -DMODVERSIONS -include /lib/modules/2.4.18-3/build/include/linux/modversions.h -DVMNS -c -o rhine_vmns.o rhine_vmns.c UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
************************************************** UVuLinux联盟
UVuLinux联盟
Build options: UVuLinux联盟
UVuLinux联盟
VERSION 2.4.18-3 UVuLinux联盟
UVuLinux联盟
SMP Disabled UVuLinux联盟
UVuLinux联盟
VMNS Enabled UVuLinux联盟
UVuLinux联盟
*************************************************** UVuLinux联盟
UVuLinux联盟
mkdir -p /lib/modules/2.4.18-3/kernel/drivers/net UVuLinux联盟
UVuLinux联盟
install -m 644 -o root rhinefet.o /lib/modules/2.4.18-3/kernel/drivers/net UVuLinux联盟
UVuLinux联盟
***** Move official driver via-rhine.o to via-rhine.o.backup UVuLinux联盟
UVuLinux联盟
mv /lib/modules/2.4.18-3/kernel/drivers/net/via-rhine.o /lib/modules/2.4.18-3/kernel/drivers/net/via-rhine.o.backup UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
/sbin/depmod -a || true UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
UVuLinux联盟
按照上面的结果显示是这样的一个过程: UVuLinux联盟
UVuLinux联盟
(1)系统把.c等文件编译成相应的.o文件. UVuLinux联盟
UVuLinux联盟
(2)然后显示系统是否支持SMP和VMNS,然后把相应的.o模块文件拷贝到系统应该的地方. UVuLinux联盟
UVuLinux联盟
(3)并且把相同芯片的程序过时的via-rhine.o改为备份文件.让系统用新的rhinefet.o UVuLinux联盟
UVuLinux联盟
(4)最后执行/sbin/depmod -a 更新模块库配置. 看来这个也是个智能的安装方法. UVuLinux联盟
UVuLinux联盟
六. 用其他方法驱动. UVuLinux联盟
UVuLinux联盟
由于市面上很多的各种各样的板卡,有名牌有杂牌,多不胜数.当我们拿到一块卡,但一下子没找到它本身提供的源程序,不能编译,怎么办呢? UVuLinux联盟
UVuLinux联盟
所以当你有一块网卡不能用,在找linux的driver之前一定搞清楚这个网卡用的什么芯片,跟谁兼容,比如3c509,ne2000,etherexpress等等. UVuLinux联盟
UVuLinux联盟
这样的型号一般都在网卡上最大的一快芯片上印着.如果芯片型号相同,那么它们其中一些是可以通用的.我们可以尝试一下系统上已经安装了的驱动是否可行了.进入驱动目录/lib/modules/(内核版本)/kernel/drivers/net 即可发现已经有很多模块了, 用命令insmod 相应芯片模块名字 , 如果不成功会报错,如果正确则不显示错误信息,然后再进行上面的"三.5-9"步骤进行测试.如果不行,再老老实实的找源程序吧.
阅读(551) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~