Issue... Ubuntu netplan gateway4/6 has been deprecated!!!
Netplan is a utility for easily configuring networking on a linux system. You simply create a YAML description of the required network interfaces and what each should be configured to do.
With the release of Ubuntu 22.04 (Jamie Jellyfish), NetPlan has changed !!!
This option is not new. In fact, you can use the same method on version 20.04.
When using netplan generate
or netplan apply
on /etc/netplan/*.yaml
you are respectively getting those error messages based on similar old methods:
######Old Method
network:
version: 2
renderer: networkd
ethernets:
eth0:
dhcp4: no
dhcp6: no
addresses: [192.168.1.137/24]
gateway4: 192.168.1.1
nameservers:
addresses: [8.8.8.8, "FEDC::1"]
Here are the errors:
netplan generate
* (generate:892): WARNING **: 09:17:45.901: `gateway4` has been deprecated, use
default routes instead. See the 'Default routes' section of the documentation
for more details.
** (generate:892): WARNING **: 09:17:45.901: `gateway6` has been deprecated, use
default routes instead. See the 'Default routes' section of the documentation
for more details.
netplan apply
WARNING: “gateway4 has been deprecated, usedefault routes instead.”
will show when running the netplan command on Ubuntu 22.04 LTS.
With thenew Ubuntu 22.04 LTS version also came a new version of netplan. This also
introducted the deprecation of gateway4 and gateway6. Netplan is the new way
to configure network settings on Ubuntu. Netplan uses yaml files for the configuration.
The gateway4 and gateway6 options will still work for now. Although the default
subiquity installation of Ubuntu 22.04 LTS still uses the gateway4 and gate6
options we should use he route: options now.
As the warning message clearly states we need to use the default routes option instead of gateway4/6:
To resolve the gateway error, you need to replace this section:
gateway4: 198.168.1.1 # Primary IPv4 gateway.
gateway6: "fe80::1"
by:
routes:
- to: default
via: 198.168.1.1 # Primary IPv4 gateway.
- to: default
via: "fe80::1"
As you can see the gateway4 options have been replaced with the routes: block.
In the routes block, we have two options:
- to: This specifies that this route is the default route for IPv4 traffic.
and
- via: 198.168.1.1: This is the IP address of the default gateway for IPv4.
All IPv4 traffic will be routed through this gateway unless a more specific route is defined.
WARNING
Each line in the block must have the correct code indentation. In other words, the amount of spaces between configuration stanzas is important. Otherwise, you may end up with an error message.
Apply configuration from netplan YAML files.
$ sudo netplan apply
In case you run into some issues execute:
$ sudo netplan --debug apply
You should now be able to access the outside world from that Server!!!. 🛠