1. 程式人生 > 其它 >ubuntu16 和ubuntu18安裝及設定靜態ip

ubuntu16 和ubuntu18安裝及設定靜態ip

1、準備ubuntu16映象
2、安裝:https://zhuanlan.zhihu.com/p/144704865
3、安裝ubuntu後,sudo passwd root這個命令建立root使用者的密碼
4、更新apt-get:apt-get -y update
5、設定靜態ip:
5.1、ifconfig檢視網絡卡名稱
5.2、修改網絡卡配置檔案sudo vim /etc/network/interfaces
# auto ens33
# iface ens33 inet dhcp
auto ens33
iface ens33 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
5.3、修改NDS配置
sudo vim /etc/resolvconf/resolv.conf.d/head
nameserver 8.8.8.8
5.4、重啟網路服務 $ sudo /etc/init.d/networking restart
5.5、重啟
5.6、(可選)安裝ssh:sudo apt-get install openssh-server






1、準備ubuntu18映象
2、安裝:https://zhuanlan.zhihu.com/p/144704865
3、安裝ubuntu後,sudo passwd root這個命令建立root使用者的密碼
4、更新apt-get:apt-get -y update
apt-get install net-tools
5、設定靜態ip:
5.1、ifconfig檢視網絡卡名稱
5.2、修改網絡卡配置檔案vim /etc/netplan/01.....
network:
version: 2
renderer: NetworkManager
ethernets:
enp3s0: #配置的網絡卡名稱,使用ifconfig -a檢視得到
dhcp4: no #dhcp4關閉
addresses: [192.168.0.10/24] #設定本機IP及掩碼
gateway4: 192.168.0.1 #設定閘道器
nameservers:
addresses: [8.8.8.8] #設定DNS
5.3、靜態ip生效
sudo netplan apply
5.4、解決resolv.conf配置檔案被覆蓋
apt-get install resolvconf
cd /etc/resolvconf/resolv.conf.d/
vim base
新增:
nameserver 8.8.8.8
nameserver 8.8.4.4
reboot