LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 02-05-2007, 10:06 AM   #1
Shioni
Member
 
Registered: Mar 2006
Posts: 182

Rep: Reputation: 30
how to find out the gateways IP?


Hi!
ifconfig doesn't list the gateway's IP? How can I found out gateways IP? Thank you!
 
Old 02-05-2007, 10:31 AM   #2
Micro420
Senior Member
 
Registered: Aug 2003
Location: Berkeley, CA
Distribution: Mac OS X Leopard 10.6.2, Windows 2003 Server/Vista/7/XP/2000/NT/98, Ubuntux64, CentOS4.8/5.4
Posts: 2,986

Rep: Reputation: 45
use the route command
Code:
route
Or go to a website like

http://whatismyip.com

or use tracepath
Code:
tracepath google.com

Last edited by Micro420; 02-05-2007 at 10:33 AM.
 
Old 02-05-2007, 01:12 PM   #3
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
Code:
netstat -ran
Will show your gateways for any configured routes (including the default route). This assumes that have already configured your gateway correctly or received it from DHCP.

If you're asking "how do I find out what my gateway should be" then you need to ask your network administrator. There's no way to find out what you should set it to if it's not already set and/or cannot be discovered with DHCP.
 
Old 02-05-2007, 02:37 PM   #4
Shioni
Member
 
Registered: Mar 2006
Posts: 182

Original Poster
Rep: Reputation: 30
Thanks! it's working!
Quote:
Originally Posted by chort
Code:
netstat -ran
If you're asking "how do I find out what my gateway should be" then you need to ask your network administrator. There's no way to find out what you should set it to if it's not already set and/or cannot be discovered with DHCP.
No, I just wanted to find out the existing one. Thanks!
 
Old 02-05-2007, 06:45 PM   #5
chort
Senior Member
 
Registered: Jul 2003
Location: Silicon Valley, USA
Distribution: OpenBSD 4.6, OS X 10.6.2, CentOS 4 & 5
Posts: 3,660

Rep: Reputation: 69
Quote:
Originally Posted by Shioni
Thanks! it's working!

No, I just wanted to find out the existing one. Thanks!
Well in case it wasn't obvious, you can find that out with netstat. Here's an example from my network:
Code:
chort@twdemos:~> netstat -ran
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
172.22.2.0      0.0.0.0         255.255.255.128 U         0 0          0 eth0
172.16.38.0     0.0.0.0         255.255.255.0   U         0 0          0 vmnet1
192.168.134.0   0.0.0.0         255.255.255.0   U         0 0          0 vmnet8
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U         0 0          0 eth1
127.0.0.0       0.0.0.0         255.0.0.0       U         0 0          0 lo
0.0.0.0         172.22.2.1      0.0.0.0         UG        0 0          0 eth0
The last line above that starts 0.0.0.0 is the "default route", i.e. your "gateway" for all traffic that hasn't been specifically routed otherwise. The second column shows the gateway IP (in this case it's 172.22.2.1).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Two gateways? candyman123 Linux - Networking 1 09-08-2005 12:36 PM
Multiple Gateways inforlinx Linux - Networking 1 02-22-2005 08:28 PM
Gateways Esmo2000 Linux - Networking 1 01-03-2005 02:49 PM
2 Gateways Equis Linux - Networking 1 11-15-2003 03:58 AM
2 Gateways def1014 Linux - Networking 3 10-24-2002 05:21 PM


All times are GMT -5. The time now is 07:42 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration