系统相关
首页 > 系统相关> > ubuntu20 IP配置

ubuntu20 IP配置

作者:互联网

1.DHCP(默认)

vi /etc/netplan/50-cloud-init.yaml
配置文件如下:

network:
    ethernets:
        ens33:
            dhcp4: yes
            addresses: []
 
    version: 2

2.静态IP

vi /etc/netplan/50-cloud-init.yaml

假设IP地址修改为192.168.1.100,子网掩码24位即255.255.255.0,网关设置为192.168.1.1,DNS1:192.168.1.1,DNS2:114.114.114.114

配置如下:

network:
    ethernets:
        ens33:
            dhcp4: no
            addresses: [192.168.1.100/24]
            optional: true
            gateway4: 192.168.1.1
            nameservers:
                    addresses: [192.168.1.1,114.114.114.114]
 
    version: 2

应用新配置

sudo netplan apply

 

标签:netplan,1.1,IP,配置,192.168,vi,ubuntu20,114.114,addresses
来源: https://www.cnblogs.com/dch0/p/15880774.html