Ubuntu设置静态IP方法
1、设置/etc/netplan/*.yaml
首先配置端口IP,vim /etc/netplan/*.yaml
# 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: disable}
network:
ethernets:
ens160:
addresses: [这里写你的IP地址/16] #/16是255.255.0.0, 24是255.255.255.0
gateway4: 写你的gateway
dhcp4: no #写true时,为DHCP分配
# optional: true
nameservers:
addresses: [10.124.224.50, 10.124.224.51]
version: 2
renderer: networkd
2、apt install network-manager安装网络管理工具
3、netplan apply 载入配置文件