How you can set a default gateway with Netplan, now that gateway4 has been deprecated

With the newest launch of Ubuntu, the tactic of defining a default gateway in Netplan has modified. Jack Wallen reveals you how one can use the brand new routes possibility.

computer with operating system linux
Picture: mtmmarek/Adobe Inventory

When Ubuntu migrated from the normal technique of managing community controllers, it despatched customers and admins right into a tizzy to shortly study the brand new technique. That technique was (and is) netplan. It’s really fairly a chic resolution for a reasonably complicated downside. Not solely is every little thing dealt with in a single handy file, every little thing is specified by JSON format—which most admins know fairly properly.

SEE: 40+ open supply and Linux phrases you’ll want to know (TechRepublic Premium)

However coinciding with the discharge of Ubuntu 22.04 (Jammy Jellyfish), Netplan has deprecated an possibility that, at first, would possibly result in some grumblings inside the group. Nevertheless, the brand new technique provides a way more handy and clever approach of defining routes, one in all which is included the default gateway.

In the event you don’t know, the default gateway is that essential handle that enables a machine to achieve the skin world. With out the gateway outlined, there’d be no WAN. So, while you first deploy Ubuntu Server 22.04, you’re going to wish to know how one can outline that default gateway.

Let me present you ways.

What you’ll want

The one stuff you’ll have to make this work are a operating occasion of Jammy Jellyfish (both as a server or desktop) and a person with sudo privileges. Are you prepared? Let’s hit the gate.

How you can outline a default gateway in Netplan

The outdated technique of defining your default gateway in Netplan was easy. Open the Netplan configuration file (on my occasion, that file is known as 00-installer-config.yaml however YMMV) and you must see the road:


Therein lies the problem, as gateway4 has been deprecated. In its favor is the routes possibility. This feature isn’t new. Actually, you would use this identical technique again in 20.04. Nevertheless, the simpler path to a default gateway was to make use of the now-deprecated gateway4 entry.

With the routes possibility, you’ll be able to set static routes to subnets (which is the way it has been primarily used). Now, nonetheless, that is the default possibility even in your gateway handle.

Let’s say your gateway handle is To outline that in Netplan, open the file for enhancing (altering the command in case your configuration file has a distinct identify) with the command:

sudo nano /and so on/netplan/00-installer-config.yaml

Find the stanza for the community interface you need to change. For me, that stanza is ens5. In that stanza, to configure the default gateway, you’d add (or edit) the next strains proper above the nameservers part:


- to: default
by way of:

Save and shut the file. Apply the configuration with the command:

sudo netplan apply

You must now be capable to attain the skin world from that server.

And that’s the way you configure the default gateway, utilizing Netplan, within the newest launch of Ubuntu Linux (22.04). In the event you’ve tried to configure a static IP in your Jammy server deployments, and might’t work out why they’re unable to get past your LAN, this would possibly properly be the explanation. And now you understand how to repair the issue.

Comfortable networking!

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the newest tech recommendation for enterprise professionals from Jack Wallen.

Source link

Be the first to comment

Leave a Reply

Your email address will not be published.