Ubuntu Server 21.10静态IP地址的设置和以前不同了.
- 默认动态IP地址对应的配置文件: /etc/netplan/*.yaml
- 设置固定ip地址
如:192.168.1.2是本机IP,192.168.1.1是网关,f4:5b:11:4c:dc:bd是网卡的MAC地址.
# 此处文件名按照自己的实际情况来
sudo nano /etc/netplan/*.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
link-local: []
optional: true
dhcp4: no
addresses:
- 192.168.1.2/24
routes:
- to: default
via: 192.168.1.1
match:
macaddress: f4:5b:11:4c:dc:bd
set-name: eth0
nameservers:
addresses: [192.168.1.1,223.5.5.5,223.6.6.6,8.8.8.8,8.8.4.4]
search: []
- 然后执行命令应用设置
sudo netplan apply
- 重启系统
sudo reboot