Ubuntu 18.04 Server 配置静态ip

刚在虚拟机里面状态了一个 Ubunut 18.04 Server 作为我的服务器,我习惯使用静态ip
首先再virtualbox中设置虚拟机网络的连接方式为桥接模式
进入ubuntu虚拟机
根据我的印象直接找到了这个配置文件

vim /etc/network/interface

打开后发现下面一段话:

# ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
# sudo apt install ifupdown

意思是现在ubuntu 18 以后默认采用netplan方式来配置网络了,原先的 ifupdown 方式不推荐了

根据提示找到默认的netplan配置文件,采用yaml配置文件格式
vim /etc/netplan/xxx.yaml

静态ip配置
network:
ethernets:
enp0s3:
addresses:
- 192.168.0.220/24
dhcp4: false
gateway4: 192.168.0.1
nameservers:
addresses:
- 8.8.8.8
version: 2

应用更改,如果配置有语法错误会有相应提示
netplan apply

猜你喜欢

转载自www.cnblogs.com/codeAB/p/12009729.html