How do I find out my Linux gateway / router IP address?

by Vivek Gite on October 2, 2007 · 17 comments

Q. 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?

A. 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. 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

You need to use command called route. It manipulates the kernel’s IP routing tables. It can also use as follows to print gateway / router IP address:
$ route -n
Output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 ra0
0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 ra0

192.168.1.1 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
Output:

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

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

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

{ 17 comments… read them below or add one }

1 Khai Luc May 29, 2008

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

Reply

2 bob September 26, 2008

nice one

Reply

3 Jino December 15, 2008

Thank you very much for the information……….

Reply

4 ndjock-abanda arthur March 6, 2009

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

thanks nix

Reply

5 Umesh Sonune May 22, 2009

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.

Reply

6 ip address June 1, 2009

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}

Reply

7 Robert January 27, 2010

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

Reply

8 vamsi February 26, 2010

route -nee

Reply

9 Veljko March 25, 2010

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 …

Reply

10 Subnet Ninja October 15, 2010

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?

Reply

11 amar February 10, 2011

router -n

Reply

12 Subnet Ninja February 15, 2011

Thanks.

Reply

13 Toshiba February 17, 2011

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.
Thanks!

Reply

14 Luis July 2, 2011

Thank you .

Reply

15 Md.Amanullah January 13, 2012

thanx…simple way,,,

Reply

16 uuryg February 3, 2012

Thanks

Reply

17 Kottha anusha February 9, 2012

thank you very much .Information is very needful.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 12 + 4 ?
Please leave these two fields as-is:
Solve the simple math so we know that you are a human and not a bot.




Previous post:

Next post: