centos7.2設定靜态ip不生效
一、檢查/etc/sysconfig/network-scripts目錄下配置檔案
1、看到了一個陌生的配置檔案 ifcfg-Wired_connection_1,度娘查詢了一下這個配置檔案是系統啟動調用的網卡配置檔案和NetworkManager服務相關。
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL2IzM4EjMwkTM3IjMwAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
2、在CentOS系統上,目前有NetworkManager和network兩種網絡管理工具。如果兩種都配置會引起沖突,而且NetworkManager在網絡斷開的時候,會清理路由,如果一些自定義的路由,沒有加入到NetworkManager的配置檔案中,路由就被清理掉,網絡連接配接後需要自定義添加上去。
二、解決方法
1、停掉NetworkManager服務
systemctl stop NetworkManager.service
2、設定開機不自動啟動
systemctl disable NetworkManager.service
----------------------輸出資訊---------------------------
Removed /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
3、systemctl is-enabled NetworkManager #檢視是否禁用
4、設定network服務開機自啟動
systemctl enable network.service
----------------------輸出資訊---------------------------
network.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig network on
5、輸出的大概意思就是需要執行一下**/sbin/chkconfig network on**
6、以上執行完成後配置你的實體網卡資訊
vim /etc/sysconfig/network-scripts/ifcfg-ens32
7、配置完成後重新開機伺服器即可
一、檢查/etc/sysconfig/network-scripts目錄下配置檔案
1、看到了一個陌生的配置檔案 ifcfg-Wired_connection_1,度娘查詢了一下這個配置檔案是系統啟動調用的網卡配置檔案和NetworkManager服務相關。
![](https://img.laitimes.com/img/9ZDMuAjOiMmIsIjOiQnIsIyZuBnL2IzM4EjMwkTM3IjMwAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
2、在CentOS系統上,目前有NetworkManager和network兩種網絡管理工具。如果兩種都配置會引起沖突,而且NetworkManager在網絡斷開的時候,會清理路由,如果一些自定義的路由,沒有加入到NetworkManager的配置檔案中,路由就被清理掉,網絡連接配接後需要自定義添加上去。
二、解決方法
1、停掉NetworkManager服務
systemctl stop NetworkManager.service
2、設定開機不自動啟動
systemctl disable NetworkManager.service
----------------------輸出資訊---------------------------
Removed /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
3、systemctl is-enabled NetworkManager #檢視是否禁用
4、設定network服務開機自啟動
systemctl enable network.service
----------------------輸出資訊---------------------------
network.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig network on
5、輸出的大概意思就是需要執行一下**/sbin/chkconfig network on**
6、以上執行完成後配置你的實體網卡資訊
vim /etc/sysconfig/network-scripts/ifcfg-ens32
7、配置完成後重新開機伺服器即可