(1)在服務器環境下建議不要使用圖形化網絡配置環境進行網絡配置,通過寫入/etc/network/interfaces網絡配置文件完成網絡配置工作,配置步驟如下:
root@user-PC:~# systemctl stop network-manager (關閉圖形化網絡配置) root@user-PC:~# systemctl disable network-manager (關閉圖形化網絡配置開機啟動) root@user-PC:~# vi /etc/network/interfaces (打開網絡配置文件進行編輯) |
按i 鍵,進入編輯模式,修改配置文件,例如:
auto enp2s0 (網卡一名稱) iface enp2s0 inet static (”enp2s0”是實際現場網卡名稱,使用ifconfig命令查看) address 192.168.0.22 (寫入實際IP地址) netmask 255.255.255.0 (子網掩碼) gateway 192.168.0.1 (寫入網關地址) |
注:網卡名稱需要根據實際環境中用ifconfig命令查看並設置。
(2)編輯完成后,按ESC,同時按住shift+:鍵,輸入wq 保存並退出配置文件。並重啟網絡服務。
root@user-PC:~# systemctl restart networking |
靜態路由配置