Netplan Gateway is Deprecated Use Default Routes on Ubuntu

When I try to use Netplan on my Ubuntu server, I get this error, Gateway 4 (or Gateway 6) has been deprecated, use the default routes instead. So I decided to show you how to fix this error. As it is obvious, you should use the routes instead of the gateway. Let’s see how it works.

Netplan is a utility developed by Canonical, the company behind Ubuntu. With Netplan, you can configure the network of your Ubuntu servers.

Fix Error Netplan Gateway is Deprecated – Use Default Routes on Ubuntu

When using Netplan, I got the below error message:

Error Message
** (generate:1952): WARNING **: ...: `gateway4` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

** (generate:1952): WARNING **: ...: `gateway6` has been deprecated, use default routes instead.
See the 'Default routes' section of the documentation for more details.

In the past, you used to define gateways. But now you should define the routes themselves.

What are the default routes instead of Gateway4 and Gateway6?

The to: and via: options are the default routes. The to: states where to route and the via: states where to route via.

Below is an example of the default routes option instead of gateway4 in Netplan on Ubuntu:

network:
  ethernets:
    ens160:
      addresses:
      - 10.10.20.6/24
      nameservers:
        addresses:
        - 10.10.20.71
      routes:
          - to: default
            via: 10.10.20.1
  version: 2

And for the gatway6 is like:

network:
  ethernets:
    ens160:
      addresses:
      - 10.10.20.6/24
      - 2001:678:e20:20::6/64
      nameservers:
        addresses:
        - 10.10.20.71
      routes:
          - to: default
            via: 10.10.20.1
          - to: default
            via: 2001:678:e20:20::1
  version: 2

That’s it, you can now easily use the default routes.

It is recommended to visit Netplan examples for more information.

Conclusion

At this point, you have learned to Fix the Error Netplan Gateway is Deprecated – Use Default Routes on Ubuntu. The to: and via: options are the default routes. You can easily use them instead of a gateway.

Hope you enjoy it. You may be interested in these articles on the Orcacore website:

How To Check Internet Speed in Linux Terminal

How To Install CloudPanel on Ubuntu and Debian

And How To Install Virtualmin GPL on Linux

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular