601176a2395e52920.jpg_fo742.jpg

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

1 对 “ubuntu18.04设置静态IP”的想法;

  1. 要注意的一点是,在 Ubuntu 18.04 里,这个配置文件的每一行都必须靠空格来缩进,不能用 TAB 来代替,否则配置会不起作用.

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

Captcha Code