Ubuntu Server 18.04 网络设置不生效的解决

在Ubuntu18.04中,传统的配置/etc/network/interfaces已无用https://www.cnblogs.com/dunitian/p/6658578.html

新方法:修改 /etc/netplan/50-cloud-init.yaml

配置如下:

network:
    ethernets:
        eth0:
            addresses: [192.168.36.202/24]
            gateway4: 192.168.36.1
            nameservers:
                    addresses: [114.114.114.114,180.76.76.76]
    version: 2


重启网络sudo netplan apply


如果网络不正常可以使用:sudo netplan --debug apply

测试一下远程连接

配置多个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:

        enp1s0f0:

            addresses: [182.255.60.205/24,182.255.60.214/24,182.255.60.201/24]

            dhcp4: false

            gateway4: 182.255.60.254

            nameservers:

                addresses: [8.8.8.8,114.114.114.114]

                search: []

        enp1s0f1:

            addresses: []

            dhcp4: true

            optional: true

    version: 2

转载于:

http://www.mamicode.com/info-detail-2459162.html

原文地址:https://www.cnblogs.com/rui517hua20/p/11318259.html