网络-网络-有网才有络络,哈哈!学习在于不断记录,问题记录多了就成大牛了。当大牛达到一定层次,都会回馈社会。研发推出新的东东!
CentOS找不到ifcfg-eth0解决方法
问题描述:
ifconfig命令无法找到eth0设备,且/etc/sysconfig/network-scripts/中只有ifcfg-lo文件,而没有ifcfg-eth0。
临时解决方法一:
使用命令ifconfig eth0 192.168.1.x/24 up 可以正常设置eth0的IP,该方法仅为临时处理办法,系统重启后即失效了。
永久解决方法二:
1、在/etc/sysconfig/network-scripts/目录下新建ifcfg-eth0文件;
2、正确设置ifcfg-eth0的DEVICE、BOOTPROTO、ONBOOT、IPADDR、GATEWAY、DNS1、DOMAIN、NETMASK、NETWORK、NAME等等,比如:
DEVICE=eth0 物理设备名称
IPADDR=192.168.1.x IP地址
NETMASK=255.255.255.0 子网掩码
NETWORK=192.168.1.0 指定网络,通过IP地址和子网掩码自动计算得到
GATEWAY=192.168.1.1 网关地址
BROADCAST=192.168.1.255 广播地址,通过IP地址和子网掩码自动计算得到
ONBOOT=[yes|no] 引导时是否激活设备
USERCTL=[yes|no] 非ROOT用户是否可以控制该设备
BOOTPROTO=[none|static|bootp|dhcp] 引导时不使用协议|静态分配|BOOTP协议|dhcp协议
HWADDR=00:13:D3:27:9F:80 MAC地址 当ethx丢失,ifconfig eth0 192.168.0.24/24 up获取MAC地址
NAME=eth0 名称
3、经过以上设置,正常情况下是可以成功的,如果仍有问题,在文件/etc/rc.d/rc.local最后加入ifup eth0(/etc/rc.local脚本是在所有其它初始化脚本执行完毕后执行)。
4、重启电脑,OK。
其它网络控制命令:
ifdown eth0、ifconfig eth0 down //关闭网络
ifup eth0、ifconfig eth0 up //开启网络
-------------------------------------------------------
设置DNS 配置文件位置/etc/resolv.conf
-------------------------------------------------------
service network start //启动网络服务
service network stop //停止网络服务
srvice network restart //重启网络服务
service network status //查看网络服务状态
问题描述:新版本的RedHat网卡配置跟以前不大一样,总结问题与解决方法如下:
1、找不到eth0文件但有网卡配置文件
在使用RedHat6.5,新装好的系统,发现没有eth0网卡,默认的第一个网卡是Auto-eth0
[root@rac01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-Auto_eth0
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.10.10.110
PREFIX=24
GATEWAY=10.10.10.111
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth0
UUID=86d44060-4579-48cc-b85b-219a206ca37c
ONBOOT=yes
HWADDR=00:50:56:95:09:76
LAST_CONNECT=1411004329
解决方法:
直接更名ifcfg-Auto_eth0文件为eth0,重启网卡后会发现,网卡名已经变为eth0
[root@rac01 ~]# service network restart
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
2、ifconfig 发现网卡服务名并未更改
[root@rac01 ~]# ifconfig
Auto_eth0 Link encap:Ethernet HWaddr 00:50:56:95:09:76
inet addr:10.10.10.110 Bcast:10.10.10.111 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe95:976/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:484 errors:0 dropped:0 overruns:0 frame:0
TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40095 (39.1 KiB) TX bytes:6271 (6.1 KiB)
解决方法:
每次更改RedHat的网卡信息,RedHat会自动的将网卡的MAC地址和对应的网卡服务名关系记录在
/etc/udev/rules.d/70-persistent-net.rules中,修改里面的对应服务名即可
[root@rac01 ~]# vim /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x15ad:0x07b0 (vmxnet3)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:0c:29:1e:f6:ad", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
修改完成后需重启一下系统,再次查看网卡服务名已经更改
[root@rac01 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:95:09:76
inet addr:10.109.67.81 Bcast:10.109.67.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe95:976/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:985 errors:0 dropped:0 overruns:0 frame:0
TX packets:61 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:74395 (72.6 KiB) TX bytes:6527 (6.3 KiB)
3、网卡eth0被删除后,新加的网卡成了eth1,如何让从eth0开始
[root@rac01 ~]# ifconfig
eth1 Link encap:Ethernet HWaddr 00:50:56:95:09:76
inet addr:10.10.10.110 Bcast:10.10.10.111 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe95:976/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:830 errors:0 dropped:0 overruns:0 frame:0
TX packets:57 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:63700 (62.2 KiB) TX bytes:6259 (6.1 KiB)
eth2 Link encap:Ethernet HWaddr 00:0C:29:1E:F6:B7
inet addr:10.10.10.120 Bcast:10.10.10.111Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1e:f6b7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:777 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:54938 (53.6 KiB) TX bytes:746 (746.0 b)
解决方法:
同2问题类似,即可以手动的修改70-persistent-net.rules文件,将对应的MAC地址与网卡序号改成想要的,也可以直接删除该文件,重启系统后,RedHat会自动的创建该文件,并从0开始计数。
删除文件,重启系统
[root@rac01 ~]# mv /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/7
0-persistent-net.rules.bak
[root@rac01 ~]# reboot
再次查看,会发现已经从eht0开始
[root@rac01 ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:56:95:09:76
inet addr:10.109.67.81 Bcast:10.109.67.255 Mask:255.255.255.0
inet6 addr: fe80::250:56ff:fe95:976/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:206 errors:0 dropped:0 overruns:0 frame:0
TX packets:68 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:19282 (18.8 KiB) TX bytes:7215 (7.0 KiB)
eth1 Link encap:Ethernet HWaddr 00:0C:29:1E:F6:B7
inet addr:10.109.67.83 Bcast:10.109.67.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe1e:f6b7/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:131 errors:0 dropped:0 overruns:0 frame:0
TX packets:11 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:8736 (8.5 KiB) TX bytes:746 (746.0 b)
4、每次重启网卡,总是提示
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/9
此时网卡也可以正常通信,这个是因为RedHat自己开发的NetworkManager管理工具和/etc/sysconfig/network-scripts/ifcfg-ethx配置不同步造成的。
解决方法:
要消除这个提示,请关闭NetworkManager服务即可:
[root@rac01 ~]# service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/2 [ OK ]
Bringing up interface eth1: Active connection state: activated
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/3 [ OK ]
关闭NetworkManager服务
[root@rac01 ~]# service NetworkManager stop
Stopping NetworkManager daemon: [ OK ]
再次重启网卡
[root@rac01 ~]# service network restart
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
Bringing up interface eth1: [ OK ]
5、重启网卡出现提示:
Bringing up interface eth0: Determining if ip address 10.109.67.81 is already in use for device eth0...
[ OK ]
Bringing up interface eth1: Determining if ip address 10.109.67.83 is already in use for device eth1...
[ OK ]
该警告一般是由于网卡解析arp协议导致的,可在网卡的配置文件中加入ARPCHECK=NO参数来屏蔽该检查
[root@rac01 ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.109.67.81
PREFIX=24
GATEWAY=10.109.67.254
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME=eth0
UUID=86d44060-4579-48cc-b85b-219a206ca37c
ONBOOT=yes
HWADDR=00:50:56:95:09:76
LAST_CONNECT=1411004329
ARPCHECK=no
再次启动网卡,一切正常
[root@rac01 ~]# service network restart
Shutting down interface eth0: [ OK ]
Shutting down interface eth1: [ OK ]
Shutting down loopback interface: [ OK ]
Bringing up loopback interface: [ OK ]
Bringing up interface eth0: [ OK ]
Bringing up interface eth1: [ OK ]
学海无涯,方在步步为营!
参考:
http://www.centoscn.com/CentosBug/osbug/2014/0309/2526.html
http://www.linuxidc.com/Linux/2014-11/109536.htm