/etc/netplan/50-cloud-init.yaml
Configure the static network under :
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
After the configuration is complete, the following error occurs when applying the network configuration:
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:~#
The error message means that gateway4
it has been deprecated, please use the default route instead. The default route is through routes
configuration IP
.
Modify the network configuration as follows:
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
Apply network configuration:
netplan apply