以下操作为
ubuntu-18.04.6版本镜像
设置网络地址为静态地址操作,如果是20.4版本镜像,配置文件是不一样的
。
打开
虚拟机修改配置文件
:
#备份原有配置
cd /etc/network/
mv interfaces interfaces.bak
cp interfaces.bak interfaces
vim interfaces
修改如下:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto ens33
iface ens33 inet static
address 192.168.120.130
netmask 255.255.255.0
gateway 192.168.120.2
dns-nameserver 114.114.114.114
#重启虚拟机
reboot