一、目录及配置文件
cd /etc/netplan
vi 01-network-manager-all.yaml
静态ip配置方式
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp4s0:
dhcp4: false
addresses: [192.168.100.87/24]
gateway4: 192.168.100.3
nameservers:
addresses: [192.168.100.3,8.8.8.8]
DHCP配置方式
# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp4s0:
dhcp4: true
重启netplan
使用 netplan apply 即可刷新IP
本文介绍了在Ubuntu系统下,通过编辑/etc/netplan/01-network-manager-all.yaml文件来配置网络接口的静态IP和动态IP。对于静态IP配置,详细列出了包括IP地址、子网掩码、网关和DNS的设置步骤;而对于动态IP配置,则只需将dhcp4设置为true。完成配置后,使用netplan apply命令即可应用新的网络设置。

1689

被折叠的 条评论
为什么被折叠?



