Ubuntu固定虛擬機ip地址的方法教程
1、由于虛擬機網(wǎng)絡(luò)是橋接,所以ip地址會不停地變化,接下來我們就講述ip如何固定
2、如果apt安裝時報錯W: Target CNF (multiverse/cnf/Commands-all) is configured multiple times in /etc/apt/sources.list:10
檢查 /etc/apt/sources.list
文件和 /etc/apt/sources.list.d/
目錄下的所有.list
文件,查找是否有重復(fù)的條目。
如果發(fā)現(xiàn)重復(fù)的條目,請刪除或注釋掉重復(fù)的條目,保留一個。我是注釋了original.list文件的配置。
3、查看網(wǎng)絡(luò)接口信息
ifconfig
apt install 之前 需要apt update
4、查看路由網(wǎng)關(guān)信息
route -n
5、更新網(wǎng)絡(luò)配置文件 一般在/etc/netplan 類似 00-installer-config.yaml
建議先安裝NetworkManager,步驟6
先備份,以免還原無果0.0
# This is the network config written by 'subiquity' network: ethernets: enp0s3: dhcp4: no addresses: - 192.168.124.150/24 gateway4: 192.168.124.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4 version: 2 renderer: NetworkManager
編輯完成使用命令 netplan apply 報了下面的錯
6、安裝NetworkManager
sudo apt update
sudo apt install network-manager 報錯了 需要apt-get update
然后再看ifconfig的ip地址就是自己設(shè)置的IP地址了
安裝NetworkManager: 首先,確保NetworkManager已安裝。打開終端并運行以下命令:
sudo apt update sudo apt install network-manager
啟用并啟動NetworkManager: 安裝完成后,啟用并啟動NetworkManager服務(wù):
sudo systemctl enable NetworkManager sudo systemctl start NetworkManager
檢查NetworkManager狀態(tài): 確認(rèn)NetworkManager正在運行:
sudo systemctl status NetworkManager
使用netplan配置網(wǎng)絡(luò)
如果不想使用NetworkManager,可以使用netplan直接配置網(wǎng)絡(luò),步驟如下:
編輯Netplan配置文件: 打開netplan配置文件進行編輯:
sudo nano /etc/netplan/01-netcfg.yaml
配置靜態(tài)IP地址: 按照以下示例配置文件進行配置:
將ens33
替換為你的網(wǎng)絡(luò)接口名稱,并根據(jù)實際情況調(diào)整IP地址、網(wǎng)關(guān)和DNS服務(wù)器。
應(yīng)用配置: 保存文件并退出編輯器,然后應(yīng)用netplan配置:
network: version: 2 renderer: networkd ethernets: ens33: dhcp4: no addresses: - 192.168.1.100/24 gateway4: 192.168.1.1 nameservers: addresses: - 8.8.8.8 - 8.8.4.4
sudo netplan apply
驗證配置: 驗證你的網(wǎng)絡(luò)配置是否正確生效:
ip addr show ens33
以上就是Ubuntu固定虛擬機ip地址的方法教程的詳細(xì)內(nèi)容,更多關(guān)于Ubuntu固定虛擬機ip地址的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
詳解Ubuntu下ssh服務(wù)的安裝與登陸(ssh遠程登陸)
本篇文章主要介紹了Ubuntu下ssh服務(wù)的安裝與登陸,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2016-11-11Linux 新的API signalfd、timerfd、eventfd使用說明
這篇文章主要介紹了Linux 新的API signalfd、timerfd、eventfd使用說明的相關(guān)資料,非常不錯具有參考借鑒價值,需要的朋友可以參考下2016-10-10linux下查看系統(tǒng)進程占用的句柄數(shù)方法
下面小編就為大家?guī)硪黄猯inux下查看系統(tǒng)進程占用的句柄數(shù)方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-11-11