Ubuntu24.04设置静态IP地址
1. 定位配置文件
ls /etc/netplan/*.yaml # 通常为 00-installer-config.yaml
2.编辑配置文件,注意空格
# This is the network config written by 'subiquity'
network:
ethernets:
ens5f0:
dhcp4: false
addresses: [ 192.168.0.251/24 ]
gateway4: 192.168.0.1
nameservers:
addresses:
- 223.5.5.5
- 8.8.8.8
ens5f1:
dhcp4: true
ens5f2:
dhcp4: true
ens5f3:
dhcp4: true
version: 2
dhcp4: false #禁用动态IP
3.应用Netplan配置:
sudo netplan apply
4.重启网络服务(可选):
sudo systemctl restart systemd-networkd
5.验证配置:
ip addr