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

 

posted @ 2022-02-10 20:51  _DC  阅读(1001)  评论(0编辑  收藏  举报