ubuntu18.04设置静态IP
vim /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource. Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
ethernets:
ens160:
addresses: [192.168.2.201/24]
dhcp4: no
gateway4: 192.168.2.1
nameservers:
addresses: [114.114.114.114,8.8.8.8]
version: 2
要注意的一点是,在 Ubuntu 18.04 里,这个配置文件的每一行都必须靠空格来缩进,不能用 TAB 来代替,否则配置会不起作用.