How To Check Default Gateway Or Router IP Address In Linux?
 

How To Check Default Gateway Or Router IP Address In Linux?

 

A large network like the internet can have multiple smaller interconnected networks. A gateway is a network node or point which serves as the access point to another network. All your traffic first goes to the router and then to the rest of the internet.

There are various ways to find gateway or router IP address in Linux a few of them are discussed here in this article.

How to find default gateway or router IP using IP command

The ip command is a very useful tool to configure network interfaces. We will use this command here to display the default gateway or router IP address.

Open your terminal and run the following command –

ip r

or you can use –

ip route

As you can see in the output of this command the IP address 192.168.122.1 is the default gateway or router IP address which is given in the first line.

Find default gateway using the route command

The route command is used to display and manipulate the IP routing table. You can use the option -n with the route command to display the default gateway. Before using this command you may need to install the net-tools package in some Linux distributions.

Use the following command to install it –

sudo apt install net-tools

After installing net-tools, run the following command –

route -n

See the output of this command the UG in the flag column corresponding to the IP address 192.168.122.1 means up(U) and gateway(G). The IP address 192.168.122.1 is the default gateway or the router IP address.

Find default gateway using netstat command

The netstat command is used to monitor the network connections also it is used to displays the routing tables, interface statics, etc. This tool is available for various operating systems including Windows.

Now use the -rn options with netstat command to display the default gateway or router IP  –

netstat -rn

The UG given in the first line of flags column means up and gateway and the IP 192.168.122.1 is the default gateway or router IP address.

Conclusion

By using any one of the given commands you can easily find the default gateway or router IP. Now if you have any queries on this you can write to us in the comments below.

Previous [lubuntu] Touchpad tap not wokring
Next Ubunut 20.04 Auto Install Encrypt Drive
 

About author

You might also like

Linux Topics 0 Comments

How To Connect A Remote Linux Server Using SSH?

This post was last updated on August 2nd, 2020 at 08:28 pmSecure Shell(SSH) is a cryptographic networking protocol for securely getting access to a remote computer with the command line

Linux Topics 0 Comments

What Is PPA And How To Add Or Remove It In Ubuntu Using Command Line?

This post was last updated on August 1st, 2020 at 09:56 pmIn the context of the Linux operating system, PPA stands for “personal package archive”. By using PPA anyone can

How To 0 Comments

How To Setup NFS In Ubuntu 20.04 LTS?

This post was last updated on August 1st, 2020 at 12:22 pmNFS or Network file system is a distributed filesystem protocol. It allows a remote host to mount filesystem over

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply