linux下网卡编译安装

说明:
用公司淘汰下来的电脑安装rhel 5.4做测试机。 装完系统后,发现只能ping自己,网关不通,重启network服务正常,会提示bringing up interface eth0: r8169: eth0: unknown chipset (mac_version=1)
网上查了些资料,貌似centos5.4 自带的网卡驱动会有点问题,需要安装官方驱动,以下是解决问题方法:

# lspci |grep Ethernet //查看网卡型号,这是显示是realtek rtl8111/8168b
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)

 
实现:
1.上网搜realtek rtl8111/8168b这款的linux driver。

# cd /usr/local/src
# tar jxvf r8168-8.037.00.tar.bz2
# cd r8168-8.037.00
# ./autorun.sh //直接autorun.sh安装,会提示以下信息
make: *** /lib/modules/2.6.18-194.el5/build: No such file or directory. Stop.
make: *** [default] Error 2

这是因为缺少kernel-headers kernel-devel内核开发环境

2.加载rhel的源,rpm安装kernel-headers kernel-devel内核开发环境

# mkdir /mnt/cdrom //建立/mnt/cdrom目录用于挂载光驱
# mount /dev/cdrom /mnt/cdrom
# cd /mnt/cdrom/Server
# rpm -ivh kernel-headers****
# rpm -ivh kernel-devel****
# cd /usr/local/src/r8168-8.037.00
# ./autorun.sh

会提示什么gcc没有安装啥的,。。。。

3.安装gcc及相应依赖库

# cd /mnt/cdrom/Server
# rpm -ivh gcc-*** //会提示依赖库,根据上面的提示rpm -ivh安装相应的库即可
# cd /usr/local/src/r8168-8.037.00
# ./autorun.sh //这时,再autorun.sh就没问题了。会出现些备份啥的
Check old driver and unload it.
rmmod r8169
Build the module and install
Backup r8169.ko
rename r8169.ko to r8169.bak
Depending module. Please wait.
load module r8168
Completed.

 
4.修改modprobe.conf,加载新驱动!

# vim /etc/modprobe.conf //修改/etc/modprobe.conf,修改以下内容,eth0为网卡名称,r8168为新网卡驱动目录
alias eth0 r8168

 
5.重启network服务

# service network restart
# ethtool -i eth0
driver: r8168
version: 8.037.00-NAPI
firmware-version:
bus-info: 0000:01:00.0

 
6.测试

# ping www.baidu.com
PING www.a.shifen.com (115.239.210.26) 56(84) bytes of data.
64 bytes from 115.239.210.26: icmp_seq=1 ttl=55 time=24.7 ms
64 bytes from 115.239.210.26: icmp_seq=2 ttl=55 time=43.4 ms
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 24.718/34.108/43.498/9.390 ms

这样,就都正常!!

发表评论

邮箱地址不会被公开。 必填项已用*标注