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 Change Username In Linux/Unix From The Terminal?

This post was last updated on August 1st, 2020 at 03:04 pmIn a Linux/Unix system sometimes you may need to change the username or User ID (UID) of a user

Linux Topics 0 Comments

How Vim Is Different From Vi?

Vi is a command-line text editor originally developed for Unix operating system. You can find it installed on almost any Unix-like operating systems including Linux, BSD, etc. Vi was originally

Linux Topics 0 Comments

How To Convert A Disk From GPT To MBR On Linux?

The firmware interface is a way by which firmware interacts with the operating system. The BIOS is the usual firmware interface while UEFI is the newer one that has some

0 Comments

No Comments Yet!

You can be first to comment this post!

Leave a Reply