LINUX6.5 同一網路卡多個配置檔案時的使用順序及格式要求

還不算暈發表於2016-01-05

先寫結果:

1.驗證ifcfg-eth2與ifcfg-eth2bak這種格式的,service network restart 時會讀取這種配置檔案
如果改為mv ifcfg-eth2bak ifcfg-eth3.bak,則不會被讀取。
2.驗證了檔名的使用順序,兩個配置檔案對應同一網路卡時,以最早使用的配置檔案的為準。

##########################################測試過程:
1.驗證ifcfg-eth2與ifcfg-eth2bak這種格式的,service network restart 時會讀取這種配置檔案
如果改為mv ifcfg-eth2bak ifcfg-eth3.bak,則不會被讀取。

[root@bys1 network-scripts]# mv ifcfg-eth3 ifcfg-eth3bak
[root@bys1 network-scripts]# mv ifcfg-eth2bak ifcfg-eth2.bak
[root@bys1 network-scripts]# service network restart
Shutting down interface eth0:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  [  OK  ]
Bringing up interface eth3bak:  
Determining IP information for eth3...^C
---改為ifcfg-eth3.bak,不會使用
[root@bys1 network-scripts]# mv ifcfg-eth3bak ifcfg-eth3.bak
[root@bys1 network-scripts]# service network restart
Shutting down interface eth0:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  [  OK  ]
----改回去 ifcfg-eth3bak驗證會使用
[root@bys1 network-scripts]# mv ifcfg-eth3.bak ifcfg-eth3bak
[root@bys1 network-scripts]# service network restart
Shutting down interface eth0:  [  OK  ]
Shutting down interface eth3bak:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  [  OK  ]
Bringing up interface eth3bak:  
Determining IP information for eth3...^C

####################################
2.測試同一網路卡,不同配置檔名時的使用順序及對應IP生效情況
驗證了檔名的使用順序,兩個配置檔案對應同一網路卡時,以最早使用的配置檔案的為準。

配置檔案情況
[root@bys1 network-scripts]# cat ifcfg-eth1
# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=08:00:27:A0:5F:E7
NETMASK=255.255.255.0
IPADDR=192.168.10.1
[root@bys1 network-scripts]# cat ifcfg-eth1bak
# Intel Corporation 82540EM Gigabit Ethernet Controller
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=08:00:27:A0:5F:E7
NETMASK=255.255.255.0
IPADDR=192.168.11.1
---實驗1;將IP192.168.10.1對應的配置檔案先讀取,後續eth1bak配置檔案不會影響。
[root@bys1 network-scripts]# 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  ]
Bringing up interface eth1bak:  [  OK  ]
[root@bys1 network-scripts]# ifconfig

eth1      Link encap:Ethernet  HWaddr 08:00:27:A0:5F:E7  
          inet addr:192.168.10.1  Bcast:192.168.10.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:104 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:15754 (15.3 KiB)  TX bytes:5698 (5.5 KiB)

--實驗2:將IP192.168.11.1對應的配置檔案先讀取,會使用此配置檔案的資訊。
[root@bys1 network-scripts]# mv ifcfg-eth1 ifcfg-eth1b
[root@bys1 network-scripts]# mv ifcfg-eth1bak ifcfg-eth1a
[root@bys1 network-scripts]# service network restart
Shutting down interface eth0:  [  OK  ]
Shutting down interface eth1a:  [  OK  ]
Shutting down loopback interface:  [  OK  ]
Bringing up loopback interface:  [  OK  ]
Bringing up interface eth0:  [  OK  ]
Bringing up interface eth1a:  [  OK  ]
Bringing up interface eth1b:  [  OK  ]
[root@bys1 network-scripts]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 08:00:27:A0:5F:E7  
          inet addr:192.168.11.1  Bcast:192.168.11.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:136 errors:0 dropped:0 overruns:0 frame:0
          TX packets:62 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:19100 (18.6 KiB)  TX bytes:9287 (9.0 KiB)

相關文章