CentOS之——CentOS 6.5 安装RTL8111/8168B PCI EXPRESS网卡并解决安装出现的问题

前端之家收集整理的这篇文章主要介绍了CentOS之——CentOS 6.5 安装RTL8111/8168B PCI EXPRESS网卡并解决安装出现的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

转载请注明出处:http://blog.csdn.net/l1028386804/article/details/78265463

一、查找并分析问题

最近,内网服务器更换了主板,总是会出现下面这样的问题:过段时间服务器就会莫名奇妙的连不上了,排除是内部网络的问题,网上有些文章说是:声卡、网卡、Hyper-Threading(超线程)技术的问题,在BIOS中将其关闭即可。但是,我尝试了还是不行,关键是网卡不能关闭呀,关闭了网卡还怎么联网啊。真的有点蛋疼。

经过大半天的折腾,突然想起了一个问题:不是更换了主板吗?会不会是更换了主板之后,主板的网卡驱动和CentOS 6.5系统的不一致导致的呢,于是在命令行中输入如下命令:

lspci -v
结果如下:
[root@localhost ~]# lspci -v    
00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06)
        Subsystem: Intel Corporation 4th Gen Core Processor DRAM Controller
        Flags: bus master,fast devsel,latency 0
        Capabilities: [e0] Vendor Specific Information: Len=0c <?>
        Kernel driver in use: hsw_uncore

00:02.0 VGA compatible controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller (rev 06) (prog-if 00 [VGA controller])
        Subsystem: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller
        Flags: bus master,latency 0,IRQ 32
        Memory at f7800000 (64-bit,non-prefetchable) [size=4M]
        Memory at e0000000 (64-bit,prefetchable) [size=256M]
        I/O ports at f000 [size=64]
        Expansion ROM at <unassigned> [disabled]
        Capabilities: [90] MSI: Enable+ Count=1/1 Maskable- 64bit-
        Capabilities: [d0] Power Management version 2
        Capabilities: [a4] PCI Advanced Features
        Kernel driver in use: i915
        Kernel modules: i915

00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05) (prog-if 30 [XHCI])
        Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI
        Flags: bus master,medium devsel,IRQ 33
        Memory at f7c00000 (64-bit,non-prefetchable) [size=64K]
        Capabilities: [70] Power Management version 2
        Capabilities: [80] MSI: Enable+ Count=1/8 Maskable- 64bit+
        Kernel driver in use: xhci_hcd
        Kernel modules: xhci-hcd

00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
        Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1
        Flags: bus master,IRQ 11
        Memory at f7c17000 (64-bit,non-prefetchable) [size=16]
        Capabilities: [50] Power Management version 3
        Capabilities: [8c] MSI: Enable- Count=1/1 Maskable- 64bit+

00:16.3 Serial controller: Intel Corporation 8 Series/C220 Series Chipset Family KT Controller (rev 04) (prog-if 02 [16550])
        Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family KT Controller
        Flags: bus master,66MHz,IRQ 19
        I/O ports at f0c0 [size=8]
        Memory at f7c15000 (32-bit,non-prefetchable) [size=4K]
        Capabilities: [c8] Power Management version 3
        Capabilities: [d0] MSI: Enable- Count=1/1 Maskable- 64bit+
        Kernel driver in use: serial

00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05) (prog-if 20 [EHCI])
        Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2
        Flags: bus master,IRQ 16
        Memory at f7c14000 (32-bit,non-prefetchable) [size=1K]
        Capabilities: [50] Power Management version 2
        Capabilities: [58] Debug port: BAR=1 offset=00a0
        Capabilities: [98] PCI Advanced Features
        Kernel driver in use: ehci_hcd

00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5) (prog-if 00 [Normal decode])
        Flags: bus master,latency 0
        Bus: primary=00,secondary=01,subordinate=02,sec-latency=0
        Capabilities: [40] Express Root Port (Slot+),MSI 00
        Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
        Capabilities: [90] Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1
        Capabilities: [a0] Power Management version 3
        Kernel driver in use: pcieport
        Kernel modules: shpchp

00:1c.2 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #3 (rev d5) (prog-if 00 [Normal decode])
        Flags: bus master,secondary=03,subordinate=03,sec-latency=0
        I/O behind bridge: 0000e000-0000efff
        Prefetchable memory behind bridge: 00000000f0000000-00000000f00fffff
        Capabilities: [40] Express Root Port (Slot+),MSI 00
        Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
        Capabilities: [90] Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #3
        Capabilities: [a0] Power Management version 3
        Kernel driver in use: pcieport
        Kernel modules: shpchp

00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05) (prog-if 20 [EHCI])
        Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1
        Flags: bus master,IRQ 23
        Memory at f7c13000 (32-bit,non-prefetchable) [size=1K]
        Capabilities: [50] Power Management version 2
        Capabilities: [58] Debug port: BAR=1 offset=00a0
        Capabilities: [98] PCI Advanced Features
        Kernel driver in use: ehci_hcd

00:1f.0 ISA bridge: Intel Corporation B85 Express LPC Controller (rev 05)
        Subsystem: Intel Corporation B85 Express LPC Controller
        Flags: bus master,latency 0
        Capabilities: [e0] Vendor Specific Information: Len=0c <?>
        Kernel driver in use: lpc_ich
        Kernel modules: lpc_ich

00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05) (prog-if 01 [AHCI 1.0])
        Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode]
        Flags: bus master,IRQ 34
        I/O ports at f0b0 [size=8]
        I/O ports at f0a0 [size=4]
        I/O ports at f090 [size=8]
        I/O ports at f080 [size=4]
        I/O ports at f060 [size=32]
        Memory at f7c12000 (32-bit,non-prefetchable) [size=2K]
        Capabilities: [80] MSI: Enable+ Count=1/1 Maskable- 64bit-
        Capabilities: [70] Power Management version 3
        Capabilities: [a8] SATA HBA v1.0
        Kernel driver in use: ahci
        Kernel modules: ahci

00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
        Subsystem: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller
        Flags: medium devsel,IRQ 18
        Memory at f7c11000 (64-bit,non-prefetchable) [size=256]
        I/O ports at f040 [size=32]
        Kernel modules: i2c-i801

01:00.0 PCI bridge: Integrated Technology Express,Inc. Device 8893 (rev 30) (prog-if 00 [Normal decode])
        Flags: bus master,latency 0
        Bus: primary=01,secondary=02,sec-latency=32
        Capabilities: [70] #00 [0000]
        Kernel modules: shpchp

03:00.0 Ethernet controller: Realtek Semiconductor Co.,Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 07)
        Subsystem: Realtek Semiconductor Co.,Ltd. Device 0123
        Flags: bus master,IRQ 35
        I/O ports at e000 [size=256]
        Memory at f0004000 (64-bit,prefetchable) [size=4K]
        Memory at f0000000 (64-bit,prefetchable) [size=16K]
        Capabilities: [40] Power Management version 3
        Capabilities: [50] MSI: Enable+ Count=1/1 Maskable- 64bit+
        Capabilities: [70] Express Endpoint,MSI 01
        Capabilities: [b0] MSI-X: Enable- Count=4 Masked-
        Capabilities: [d0] Vital Product Data
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Virtual Channel
        Capabilities: [160] Device Serial Number 00-00-00-00-68-4c-e0-00
        Kernel driver in use: r8169
        Kernel modules: r8169
其中
03:00.0 Ethernet controller: Realtek Semiconductor Co.,Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 07)
.........
        Kernel driver in use: r8169
        Kernel modules: r8169
对比可以看出,主板的网卡型号为RTL8111/8168/8411, 但是系统加载的网卡型号却是r8169。

哈哈终于找到问题了,真TM爽!

二、解决问题

找到了问题,那么接下来就是解决问题了。

1、升级内核

检查是否已经安装kernel-devel, gcc

# rpm -q kernel-devel
# rpm -q gcc
如果没有安装,使用yum安装
# yum install gcc 
# yum install kernel kernel-devel kernel-headers 

2、下载RTL8111/8168B PCI EXPRESS 网卡驱动

百度搜索 RTL8111/8168B PCI EXPRESS 网卡驱动 下载,保存,也可以到链接http://download.csdn.net/download/l1028386804/10026716下载,这里我下载的包是:r8168-8.037.00.tar.bz2

3、解压安装

tar -jxvf r8168-8.037.00.tar.bz2   或者 tar jxvf r8168-8.037.00.tar.bz2
切换到r8168-8.037.00目录下,目录结构如下:
-rwxr-xr-x. 1 root root 1891 Nov 24  2011 autorun.sh
-rw-r--r--. 1 root root 2851 Oct 17 19:47 log.txt
-rw-r--r--. 1 root root 1817 May 30  2013 Makefile
-rw-r--r--. 1 root root 4072 Jan 13  2010 README
drwxr-xr-x. 3 root root 4096 Oct 17 19:47 src
这个驱动程序做的非常的好,除了驱动程序写好之外,还给我们写好Makefile、提供方便的脚本帮我们编译、打包、修改启动内核文件,卸载旧驱动、添加新驱动,详细信息可以查看README文件中的说明。
对于这个驱动程序文件我们只要执行下面的命令就可以:
./autorun.sh 

三、问题又来了

1、make: *** /lib/modules/2.6.32-431.el6.x86_64/build/: No such file or directory. Stop.

开始运行./autorun.sh脚本的时候报出:

make: *** /lib/modules/2.6.32-431.el6.x86_64/build/: No such file or directory. Stop.  
解决方案参考:博文《 CentOS之——make: *** /lib/modules/2.6.32-431.el6.x86_64/build/: No such file or directory. Stop.

2、error implicit declaration of function 'vlan_tx_tag_present' error implicit declaration of function 'vlan_tx_tag_get'

解决了上面的问题又报出了如下问题:

error implicit declaration of function 'vlan_tx_tag_present'    error implicit declaration of function 'vlan_tx_tag_get' 
经过一番努力,得知:

原来是内核更新后,函数vlan_tx_tag_present改名成了skb_vlan_tag_present,函数vlan_tx_tag_get改名成了skb_vlan_tag_get
,所以这里需要在r8168_n.c文件添加两个宏,如下所示:

#define vlan_tx_tag_get skb_vlan_tag_get
#define vlan_tx_tag_present skb_vlan_tag_present

四、问题解决

再次运行./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
DEPMOD 2.6.32-696.13.2.el6.x86_64
load module r8168
Completed.
没有报任何错误

五、验证网卡

输入命令

lspci -v 
输出的结果为:
[root@localhost kernels]# lspci -v    
00:00.0 Host bridge: Intel Corporation 4th Gen Core Processor DRAM Controller (rev 06)
        Subsystem: Intel Corporation 4th Gen Core Processor DRAM Controller
        Flags: bus master,MSI 01
        Capabilities: [b0] MSI-X: Enable- Count=4 Masked-
        Capabilities: [d0] Vital Product Data
        Capabilities: [100] Advanced Error Reporting
        Capabilities: [140] Virtual Channel
        Capabilities: [160] Device Serial Number 00-00-00-00-68-4c-e0-00
        Kernel driver in use: r8168
        Kernel modules: r8168
对比结果得出:
03:00.0 Ethernet controller: Realtek Semiconductor Co.,Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 07)
.........
        Kernel driver in use: r8168
        Kernel modules: r8168
可知,主板网卡与系统加载网卡型号一致,问题解决 原文链接:/centos/375542.html

猜你在找的CentOS相关文章