Ubuntu Server 18.04 设置静态ip

912 阅读1分钟

1. hyper-v 安装

安装的时候镜像地址:mirrors.aliyun.com/ubuntu

hyper-v 设置网络:外部交换网络

2. 设置静态ip

# 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:
        eth0:
            dhcp4: no
            dhcp6: no
            addresses: [192.168.0.102/24]
            gateway4: 192.168.0.1
            nameservers:
                    addresses: [8.8.8.8]

    version: 2
sudo netplan apply ## 生效