Technology and General Blog

To obtain the net, a gateway plays a essential position. For accessing other devices on a network or products like desktops, they need to be configured either immediately or manually by a network or method administrator. Conversation amongst diverse products is needed to route facts packets when they travel across a community. A system’s routing desk decides which network interface should really deliver these packets to remote techniques or units. Community equipment are employed for this goal, whilst routing can be performed by any unit configured as a router.

A default gateway is applied for site visitors not destined for the nearby network and for which no individual route is favored inside of the routing desk. In the same way, site visitors of static routes need to not or will need not go by using a default gateway. Traditionally, a default gateway serves as the devoted network router.

What will we include?

This guideline will learn how to established up a default gateway on Ubuntu 20.04 (Focal Fossa) OS using the ‘ip route’ and ‘route’ command. Enable us get began with this HowTo.

What are the Conditions?

Right before you start off with this tutorial, appear at the next prerequisites:

  1. Ubuntu 20.04 put in on your technique with online connectivity.
  2. Root consumer account or person account with ‘sudo’ privileges.
  3. Fundamental information of laptop networks and Ubuntu administration.

Precaution: Please observe that this is a really highly developed technological tutorial. Only endeavor to stick to this manual if you know what you are executing. If you are a newbie and conclude up messing with community configuration, you may shed your link to the web.

Experimental Set up

For this guideline, we will use IP (enp0s8) as the default gateway tackle, the IP deal with of a single of the interfaces on our Ubuntu machine (VM1). The other interface has a unique IP handle which is (enp0s3). Now comes the VM2, which has only 1 interface with IP tackle (enp0s3). It is very clear that VM2 enp0s3 can’t accessibility VM1 enp0s3 as the two are on diverse network addresses.

Our endeavor is to make each VMs talk on interfaces with different network addresses. We will established the IP of VM1( as a gateway for a further equipment (VM2), and we will then verify by pinging VM1 from VM2 to see if it can attain it the gateway.

VM1 (enp0s8) (enp0s3)

Acquiring the Default Gateway IP

Let us initially check out the default gateway that is currently established on our device, for this operate the command:

This will show the default gateway on the terminal.

Alternatively, we can use the ‘route’ command for the exact intent:

If you get an mistake like ‘Command ‘route’ not uncovered’, then you can put in the ‘route’ command with:

sudo apt install internet-equipment

Check the UG flag to glimpse for the Gateway. Routing desk flags and their meanings are given underneath:

U : UP— signifies that the route is up and legitimate
H : Host— focus on is to a host
G : Gateway—means that the route is to a gateway
R : Reject— It is set by ARP when an entry is expired
D : Dynamic— Route added by a routing redirect
M : Modified— Route modified by a routing redirect

The output of the above two commands is practically equivalent. An additional way is to use the ‘netstat -rn’ command to look at the gateway IP.

Placing Default Gateway Using the ‘ip’ Command

To start with, we will use the ‘ip’ command to established the default gateway on VM2. For this, comply with the actions mentioned beneath:

Action 1. Open a terminal (Ctrl+Alt+F2) and run the command:

sudo ip route insert default by means of

Step 2. Now ping the VM1 from VM2 to check out if our gateway is obtainable:

To delete the higher than default route, use the command underneath:

sudo ip route del default by means of

To affirm the previously mentioned adjustments, use the “route -n” command.

Location Default Gateway Employing the ‘route’ Command

Now we will use the ‘route’ command to established the default gateway on VM2. For this, stick to the techniques pointed out below:

Move 1. Open a terminal (Ctrl+Alt+F2) and operate the command:

sudo route incorporate default gw

Action 2. Now ping the VM1 from VM2 to examine if our gateway is accessible:

To delete the earlier mentioned default route, use the command under:

sudo route del default gw

To affirm the higher than variations, use the “route -n” command.


In this guideline, we have realized about environment the default gateway on Ubuntu 20.04. Try to make unique eventualities of products and hook up them applying a common gateway.

Leave a Reply

Your email address will not be published. Required fields are marked *