19

I newly installed Ubuntu 22.04 and configured netplan like this:

network:
    version: 2
    ethernets:
        ens18:
            addresses:
            - 10.10.0.101/24
            - 2009:470:1099:10::101/64
            dhcp4: false
            dhcp6: false
            accept-ra: false
            gateway4: 10.10.0.1
            gateway6: 2009:470:1099:10::1
            nameservers:
                addresses:
                - 8.8.8.8
                - 2001:4860:4860::8888

After boot I get this warning

** (generate:1099): WARNING **: 15:10:35.646: `gateway4` has been deprecated, use default routes instead.
    See the 'Default routes' section of the documentation for more details.
** (generate:1099): WARNING **: 15:10:35.646: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

How to get rid of this warning?

2 Answers2

33

Please see:

cat /usr/share/doc/netplan/examples/static.yaml

Please amend your netplan file to use the current method; for example:

routes: 
    - to: default
      via: 10.10.10.1

Follow with:

sudo netplan generate
sudo netplan apply
chili555
  • 61,330
0

I found with 2 NICs using the routes: command throws errors, even with the metric: command used for each route.

Using gateway4: & gateway6: for each interface works. It is not the recommended syntax as chili555 says though.

See the following for an excellent breakdown of current syntax:

Netplan Configuration Examples