我是Linux方面的菜鸟,但这个问题足足困扰了我5天,终于圆满解决,于是决定整理下,作为自己学习编程的第一篇博客,希望能给遇到同样问题的童鞋一点帮助……
一、问题的现象:
安装完后不能上网,/etc/sysconfig/network-scripts/目录下ifcfg打头的文件名只有ifcfg-lo,没有ifcfg-eth0文件(在其它博客上看到,有时不一定是这个名字)说明驱动没安装。
驱动没安装:
[sc@localhost 桌面]$ ifconfig -a
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:24 errors:0 dropped:0 overruns:0 frame:0
TX packets:24 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1696 (1.6 KiB) TX bytes:1696 (1.6 KiB)
二、问题解决:
1、查看网卡型号:
[sc@localhost 桌面]$ lspci
00:00.0 Host bridge: Intel Corporation Device 1918 (rev 07)
00:02.0 VGA compatible controller: Intel Corporation Device 191d (rev 06)
00:14.0 USB controller: Intel Corporation Device a12f (rev 31)
00:14.2 Signal processing controller: Intel Corporation Device a131 (rev 31)
00:16.0 Communication controller: Intel Corporation Device a13a (rev 31)
00:16.3 Serial controller: Intel Corporation Device a13d (rev 31)
00:17.0 SATA controller: Intel Corporation Device a102 (rev 31)
00:1f.0 ISA bridge: Intel Corporation Device a149 (rev 31)
00:1f.2 Memory controller: Intel Corporation Device a121 (rev 31)
00:1f.3 Audio device: Intel Corporation Device a170 (rev 31)
00:1f.4 SMBus: Intel Corporation Device a123 (rev 31)
00:1f.6 Ethernet controller: Intel Corporation Device 15b7 (rev 31)
最后一行表示网卡的型号Intel Corporation Device 15b7 (rev 31),下载的地址为点击打开链接。
2、安装gcc
下载下来后开始安装驱动。但由于软件安装需要gcc编译,而我的centos 6.5也没有预装gcc,于是先开始安装gcc:
安装gcc前需要安装其它依赖软件包,这些软件包可以从原安装盘的“Packages”文件夹里找到,当然网上找也没问题。
[sc@localhost Packages]$ su
密码:
[root@localhost Packages]# rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm
[root@localhost Packages]# rpm -ivh libmpcdec-1.2.6-6.1.el6.x86_64.rpm
[root@localhost Packages]# rpm -ivh kernel-headers-2.6.32-431.el6.x86_64.rpm
[root@localhost Packages]# rpm -ivh glibc-devel-2.12-1.132.el6.x86_64.rpm
[root@localhost Packages]# rpm -ivh glibc-headers-2.12-1.132.el6.x86_64.rpm
[root@localhost Packages]# rpm -ivh cpp-4.4.7-4.el6.x86_64.rpm
warning: cpp-4.4.7-4.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:cpp ########################################### [100%]
安装完后想安装gcc,发现又有一些依赖软件包未安装,于是又做如下安装(由于依赖关系,需要依次安装):
[root@localhost Packages]# rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm
warning: ppl-0.10.2-11.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:ppl ########################################### [100%]
[root@localhost Packages]# rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
warning: cloog-ppl-0.15.7-1.2.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:cloog-ppl ########################################### [100%]
[root@localhost Packages]# rpm -ivh gcc-4.4.7-4.el6.x86_64.rpm
warning: gcc-4.4.7-4.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:gcc ########################################### [100%]
查看gcc版本,证实已完成安装:
[root@localhost Packages]# rpm -qa | grep ^gcc
gcc-4.4.7-4.el6.x86_64
3、安装网卡驱动
[sc@localhost B4FE-5315]$ su
密码:
[root@localhost B4FE-5315]# tar -zxvf e1000e-3.4.0.2.tar.gz
e1000e-3.4.0.2/
e1000e-3.4.0.2/README
tar: e1000e-3.4.0.2/README:无法将所有权改为 uid 0,gid 0: 不允许的操作
e1000e-3.4.0.2/pci.updates
由于我的驱动程序是放在U盘上的,没有权限执行安装,于是将其拷贝到/srv目录下,完成解压:
[sc@localhost srv]$ su
密码:
[root@localhost srv]# tar -zxvf e1000e-3.4.0.2.tar.gz
e1000e-3.4.0.2/
e1000e-3.4.0.2/README
e1000e-3.4.0.2/pci.updates
e1000e-3.4.0.2/e1000e.spec
e1000e-3.4.0.2/COPYING
e1000e-3.4.0.2/e1000e.7
e1000e-3.4.0.2/SUMS
……
在执行make&make install之前需要确认kernel-headers、kernel、kernel-firemware、kernel-headers等工具是否安装,至于原理请参考点击打开链接
[root@localhost src]# rpm -qa | grep ^kernel
kernel-firmware-2.6.32-431.el6.noarch
kernel-headers-2.6.32-431.el6.x86_64
kernel-2.6.32-431.el6.x86_64
发现我的系统少安装了kernel-devel,于是打开“Packages”下的终端,安装该软件包:
[root@localhost Packages]# rpm -ivh kernel-devel-2.6.32-431.el6.x86_64.rpm
warning: kernel-devel-2.6.32-431.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Preparing... ########################################### [100%]
1:kernel-devel ########################################### [100%]
[root@localhost src]# make
[root@localhost src]# make install
make -C /lib/modules/2.6.32-431.el6.x86_64/build CC=gcc SUBDIRS=/srv/e1000e-3.4.0.2/src modules
make[1]: Entering directory `/usr/src/kernels/2.6.32-431.el6.x86_64'
Building modules, stage 2.
MODPOST 1 modules
make[1]: Leaving directory `/usr/src/kernels/2.6.32-431.el6.x86_64'
gzip -c ../e1000e.7 > e1000e.7.gz
# remove all old versions of the driver
find /lib/modules/2.6.32-431.el6.x86_64 -name e1000e.ko -exec rm -f {} \; || true
find /lib/modules/2.6.32-431.el6.x86_64 -name e1000e.ko.gz -exec rm -f {} \; || true
install -D -m 644 e1000e.ko /lib/modules/2.6.32-431.el6.x86_64/updates/drivers/net/e1000e/e1000e.ko
/sbin/depmod -a 2.6.32-431.el6.x86_64 || true
install -D -m 644 e1000e.7.gz /usr/share/man/man7/e1000e.7.gz
man -c -P'cat > /dev/null' e1000e || true……
载入网卡驱动模块(depmod的功能点击打开链接):
[root@localhost src]# depmod -a
[root@localhost src]# modprobe e1000e
[root@localhost src]# lsmod
Module Size Used by
e1000e 270937 0
ptp 9614 1 e1000e
pps_core 11458 1 ptp
fuse 73530 0
最后的lsmod指令是查看驱动程序是否加载完成,可以看到列表多了e1000e一行,说明驱动加载成功。
[root@localhost src]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 3C:52:**:**:**:**
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:16 Memory:d1000000-d1020000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:66 errors:0 dropped:0 overruns:0 frame:0
TX packets:66 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4834 (4.7 KiB) TX bytes:4834 (4.7 KiB)
[sc@localhost network-scripts]$ su
密码:
[root@localhost network-scripts]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
进入vi编辑器创建ifcfg-eth0文件,内容如下:
HWADDR=3C:52:**:**:**:D9
TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="dhcp"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="eht0"
UUID="e2aa4dea-7d69-4a5e-ac48-00********927"
DEVICE="eth0"
ONBOOT="yes"
以上是DHCP的配置,如果是静态IP请参考其它网站。
ifup eth0开启网口后,完成配置。
[root@localhost network-scripts]# ifup eth0
正在决定 eth0 的 IP 信息...完成。
/etc/sysconfig/network-scripts/ifup-ipv6: line 56: /etc/sysconfig/network: 没有那个文件或目录
/etc/sysconfig/network-scripts/ifup-aliases: line 116: /etc/sysconfig/network:
没有那个文件或目录
[root@localhost network-scripts]# ifconfig
eth0 Link encap:Ethernet HWaddr 3C:52:82:5D:1A:D9
inet addr:192.168.0.100 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::3e52:82ff:fe5d:1ad9/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:854 (854.0 b) TX bytes:1236 (1.2 KiB)
Interrupt:16 Memory:d1000000-d1020000
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:298 errors:0 dropped:0 overruns:0 frame:0
TX packets:298 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:22906 (22.3 KiB) TX bytes:22906 (22.3 KiB)
至此,打开百度网站,成功实现上网。