網絡-網絡-有網纔有絡絡,哈哈!學習在於不斷記錄,問題記錄多了就成大牛了。當大牛達到必定層次,都會回饋社會。研發推出新的東東!html
CentOS找不到ifcfg-eth0解決方法linux
問題描述:vim
ifconfig命令沒法找到eth0設備,且/etc/sysconfig/network-scripts/中只有ifcfg-lo文件,而沒有ifcfg-eth0。centos
臨時解決方法一:網絡
使用命令ifconfig eth0 192.168.1.x/24 up 能夠正常設置eth0的IP,該方法僅爲臨時處理辦法,系統重啓後即失效了。工具
永久解決方法二:oop
一、在/etc/sysconfig/network-scripts/目錄下新建ifcfg-eth0文件;學習
二、正確設置ifcfg-eth0的DEVICE、BOOTPROTO、ONBOOT、IPADDR、GATEWAY、DNS一、DOMAIN、NETMASK、NETWORK、NAME等等,好比:spa
DEVICE=eth0 物理設備名稱rest
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 名稱
三、通過以上設置,正常狀況下是能夠成功的,若是仍有問題,在文件/etc/rc.d/rc.local最後加入ifup eth0(/etc/rc.local腳本是在全部其它初始化腳本執行完畢後執行)。
四、重啓電腦,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網卡配置跟之前不大同樣,總結問題與解決方法以下:
一、找不到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
二、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)
三、網卡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)
四、每次重啓網卡,老是提示
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 ]
五、重啓網卡出現提示:
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