1.查看當(dāng)前ip地址(ifconfig)
root@wangxiao:~# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.247.128 netmask 255.255.255.0 broadcast 192.168.247.255
網(wǎng)卡名稱:ens33
2.修改靜態(tài)地址
配置/etc/network/interfaces已無用
修改/etc/netplan/50-cloud-init.yaml
默認(rèn):
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:
ens33:
addresses: []
dhcp4: true
version: 2
修改為
network:
ethernets:
ens33:
addresses: [192.168.1.150/24]
dhcp4: no
gateway4: 192.168.1.1
version: 2
3.使配置生效
netplan apply