How Do I Find Out My Linux Gateway / Router IP Address?

by on October 2, 2007 · 32 comments· LAST UPDATED July 30, 2013

in , ,

How do I find out my gateway IP for a computer or a network device that allows or controls access to another computer or network under Linux / UNIX operating systems?

A gateway is a network point that acts as an entrance to another network. On the Internet, a node or stopping point can be either a gateway node or a host (end-point) node. Both the computers of Internet users and the computers that serve pages to users are host nodes.
Tutorial details
DifficultyEasy (rss)
Root privilegesYes
Estimated completion timeLess than a minute
The computers that control traffic within your company's network or at your local Internet service provider (ISP) are gateway nodes. In the network for an enterprise, a computer server acting as a gateway node is often also acting as a proxy server and a firewall server. A gateway is often associated with both a router, which knows where to direct a given packet of data that arrives at the gateway, and a switch, which furnishes the actual path in and out of the gateway for a given packet.

Find out Gateway / router IP address under Linux / UNIX using route command

You need to use route command. This command can manipulates the kernel’s IP routing tables. It can be also use to print gateway / router IP address. Type the following command to see default gateway:
$ route -n

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface   U     0      0        0 ra0         UG    0      0        0 ra0 is gateway IP address for our computer. The flag U indicates that route is up and G indicates that it is gateway. You can print gateway name, enter:
$ route

Destination     Gateway         Genmask         Flags Metric Ref    Use Iface     *        U     0      0        0 ra0
default         wrt            UG    0      0        0 ra0

Second column prints Gateway hostname / IP address. In our example wrt is gateway.

netstat command example to find out gateway/router IP

Open a terminal and type the following command:
# netstat -r -n
Sample outputs:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface         UG        0 0          0 eth1   U         0 0          0 eth1

route and netstat command demo

Animated gif 01: Use route and netstat command to find out default gateway/router IP address on Linux

Animated gif 01: Use route and netstat command to find out default gateway/router IP address on Linux

Tweet itFacebook itG+ itDownload PDF versionFound an error/typo on this page?

{ 32 comments… read them below or add one }

1 Khai Luc May 29, 2008 at 7:37 pm

The route command you mentioned helps solve my problem. Thanks!


2 bob September 26, 2008 at 2:54 am

nice one


3 Jino December 15, 2008 at 8:40 am

Thank you very much for the information……….


4 ndjock-abanda arthur March 6, 2009 at 12:09 pm

an add , if allowed :
the command “netstat -r” could also reached the same result.

thanks nix


5 Umesh Sonune May 22, 2009 at 5:56 am

in our college we have linux proxy server for internet, troughe is a bsnl DSL router. router ip is chenged by our administrator so, i just want to know router ip from my pc which have windows xp for direct internet acsses, can u tell me what i have to do for this? plzzzzzzzzzzz help me.


6 chetan November 1, 2012 at 3:37 pm

there is a way, use a software called colasoft capsa on your computer. It will give all the IP address in use, now try each IP address you think may be a gateway and you will get to the internet. But I just want to know which BSNL router you are using?


7 chetan November 1, 2012 at 3:38 pm

There is one more issue that if you are going through linux proxy server, it is difficult to go through it, remember it is difficult not impossible. Just you have to go 1 step ahead your administrator


8 ip address June 1, 2009 at 6:32 am

i’m working in corporate office … i want to know ip address of router even some of them told that default gateway is the ip address i telnet it but not connecting … how i have to found the ip address . send to my mail if u have the idea {snip_email_id_removed}


9 chetan November 1, 2012 at 3:40 pm

Let me clear you can not telnet each device on the network. So try ping command first
syntex is


10 Robert January 27, 2010 at 12:53 am

i tried that but it does not have anything except a (*) in the gateway column. what should I do?


11 vamsi February 26, 2010 at 9:36 pm

route -nee


12 Veljko March 25, 2010 at 9:12 am

How to find gateways of multiple intrefaces? I have two interfaces, one is default, and it’s OK, but I need gateway of second interface …


13 Subnet Ninja October 15, 2010 at 12:50 pm

For some reason, when I type the router’s IP address in a Firefox address bar, it doesn’t show up… any tips for solving this annoyance?


14 amar February 10, 2011 at 11:53 am

router -n


15 Subnet Ninja February 15, 2011 at 7:43 pm



16 Toshiba February 17, 2011 at 3:22 am

Hello Vivek,
Is there a way to get version, model number and other pertinent info of Linksys router via linux? I have an ancient router with the relevant tags scratched up.


17 chetan November 1, 2012 at 3:32 pm

Just open the router settings, you will get the model number and versions their


18 Luis July 2, 2011 at 6:20 pm

Thank you .


19 Md.Amanullah January 13, 2012 at 11:36 am

thanx…simple way,,,


20 uuryg February 3, 2012 at 10:30 am



21 Kottha anusha February 9, 2012 at 10:59 am

thank you very much .Information is very needful.


22 Ahsan April 4, 2012 at 5:18 am

Access Denied Help Me PLzzzzzZZZZzzzzz


23 Matthew October 22, 2012 at 4:48 pm

Add “sudo” before it.


24 chetan November 1, 2012 at 3:33 pm

sudo cant work if user is not added in sudoers file


25 Ricardo Meleiro April 9, 2012 at 3:51 pm

Thanks for the information ! Very helpful!


26 joyce August 9, 2012 at 10:05 am

thank u so much… it was very helpful


27 Cristian September 27, 2012 at 10:33 am

THX man. learning linux now and i like it. it is so complex, so many things to learn :D


28 Zhei Kent October 3, 2012 at 6:20 am

thanks :)


29 dinesh Rao July 22, 2013 at 1:19 pm



30 Walle April 2, 2014 at 5:12 am

Hi. I ve seen a couple of very helpful replies here so I was hoping to get an answer to my problem here.

I am located in Japan and got my self an internet contract. It looks like a DSL router. Though I am not sure what I actually ordered. The usual way to establish connection is only by a CD on Windows. I am pretty sure I can somehow make that darn thing work with Ubuntu as well, I just dont know how.

If editing a DSL connection to the Network Manager it still doesnt work. But I am not very skilled with that. There I tiped in my User data and thats it. I dont know wether of how to fill out the PPPoE or do it automatically. I also wouldnt know the addresse to fill in here.

Then I also tried some sudo pppoe config command but that wouldnt help me either. Afterwards I would always have to get to the etc/network/interfaces file to set everything back so that it wouldnt take 10 times longer to start the laptop cause of the wrong network configurations.

I thought to myself it could be done by accessing the router with an Windows Laptop, but I dont know my neighbours too well to borrow one. However do you think that might be a solution as well ?

Thanks for your comments in advance



31 jim August 6, 2014 at 10:27 am

if you plug the router in and turn it on, plug a network cable between your linux computer, it should connect just by using DHCP… The CDs ISPs give out have bloatware like anti-virus, online backup storage (never enough!), dumb wireless managers etc. A network is a netowrk, and there is no need for all the software on the CD…


32 Amit Saha September 14, 2014 at 1:07 pm

Nice description…Thanks..


Leave a Comment

Tagged as: , , , , , , , , ,

Previous Faq:

Next Faq: