在 /etc/netplan/50-cloud-init.yaml 下配置静态网络:
network:
ethernets:
eth0:
dhcp4: false
addresses: [192.168.1.11/24]
optional: true
gateway4: 192.168.1.1
nameservers:
addresses: [192.168.1.1]
version: 2
配置完成后应用网络配置的时候出现以下报错:
root@k8s-master-01:~# netplan apply
** (generate:234574): WARNING **: 14:21:04.809: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
** (process:234572): WARNING **: 14:21:06.172: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.
root@k8s-master-01:~#
报错的意思是说,gateway4 已被弃用,请改用默认路由。默认路由就是通过 routes 配置 IP。
修改网络配置如下:
network:
ethernets:
eth0:
dhcp4: false
addresses: [192.168.1.11/24]
optional: true
routes:
- to: default
via: 192.168.1.1
nameservers:
addresses: [192.168.1.1]
version: 2
应用网络配置:
netplan apply


本文档介绍了在Ubuntu系统中,由于`gateway4`被弃用而遇到的网络配置错误。在尝试配置静态IP时,报错提示应使用默认路由代替。解决方案是将配置文件中的`gateway4`改为`routes`,并添加`to: default`和`via`参数来指定默认网关。应用修改后的配置并使用`netplan apply`命令,以解决网络配置问题。
7280

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



