Ubuntu22.04 静态IP地址
Ubuntu从 17.10 开始,已放弃在 /etc/network/interfaces
里固定IP的配置,而是改成 netplan 方式,配置文件是:/etc/netplan/01-netcfg.yaml
# This is the network config written by 'subiquity' network: ethernets: ens33: addresses: - 192.168.0.100/24 gateway4: 192.168.0.1 nameservers: addresses: - 222.246.129.80 search: - 59.51.78.210 version: 2
注意缩进严格对齐,ens33可以替换为你的网卡名称,24代表掩码是255.255.255.0
应用新的网络配置
sudo netplan apply