How to get IP address using terminal

Asked by Master

I am inside an internal network. Internal network users uses internet through some gateway. When I surf the website like "ipaddressworld.com". It shows some ip address and that is our gateway's external ip address. I want that IP address from my terminal by issuing some command. I don't want to surf that website.

So what is the command to know Gateway's External IP address.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu dhcp3 Edit question
Assignee:
No assignee Edit question
Solved by:
Deapesh
Solved:
Last query:
Last reply:
Revision history for this message
Tom (tom6) said :
#1

I think "ifconfig" gives a lot of info, does it include what you are looking for?

Revision history for this message
Master (master-4-master) said :
#2

No, It does not give.
It gives the information related to my PC.

Can we read a website from Terminal. If yes how?
If it is possible then I will read "www.ipaddressworld.com" from terminal. And It will give me Gateway's External IP.

I can't install any software package to gateway so I can't use terminal-browser like lynx(http://lynx.browser.org/)

Revision history for this message
Bhavani Shankar (bhavi) said :
#3

Its easy

use whois command

Ex: bhavani@hardy:~$ whois google.com

Whois Server Version 2.0

Domain names in the .com and .net domains can now be registered
with many different competing registrars. Go to http://www.internic.net
for detailed information.

   Server Name: GOOGLE.COM.ZZZZZ.GET.LAID.AT.WWW.SWINGINGCOMMUNITY.COM
   IP Address: 69.41.185.195
   Registrar: TUCOWS INC.
   Whois Server: whois.tucows.com
   Referral URL: http://domainhelp.opensrs.net

   Server Name: GOOGLE.COM.ZZZZZ.DOWNLOAD.MOVIE.ONLINE.ZML2.COM
   IP Address: 64.28.187.63
   Registrar: DIRECTI INTERNET SOLUTIONS PVT. LTD. D/B/A PUBLICDOMAINREGISTRY.COM
   Whois Server: whois.PublicDomainRegistry.com
   Referral URL: http://www.PublicDomainRegistry.com

   Server Name: GOOGLE.COM.ZOMBIED.AND.HACKED.BY.WWW.WEB-HACK.COM
   IP Address: 217.107.217.167
   Registrar: ONLINENIC, INC.
   Whois Server: whois.onlinenic.com
   Referral URL: http://www.OnlineNIC.com

   Server Name: GOOGLE.COM.YAHOO.COM.MYSPACE.COM.YOUTUBE.COM.FACEBOOK.COM.THEYSUCK.DNSABOUT.COM
   IP Address: 72.52.190.30
   Registrar: GODADDY.COM, INC.
   Whois Server: whois.godaddy.com
   Referral URL: http://registrar.godaddy.com

   Server Name: GOOGLE.COM.WORDT.DOOR.VEEL.WHTERS.GEBRUIKT.SERVERTJE.NET
   IP Address: 62.41.27.144
   Registrar: KEY-SYSTEMS GMBH
   Whois Server: whois.rrpproxy.net
   Referral URL: http://www.key-systems.net

   Server Name: GOOGLE.COM.VN
   Registrar: ONLINENIC, INC.
   Whois Server: whois.onlinenic.com
   Referral URL: http://www.OnlineNIC.com

   Server Name: GOOGLE.COM.UY
   Registrar: DIRECTI INTERNET SOLUTIONS PVT. LTD. D/B/A PUBLICDOMAINREGISTRY.COM
   Whois Server: whois.PublicDomainRegistry.com
   Referral URL: http://www.PublicDomainRegistry.com

   Server Name: GOOGLE.COM.UA
   Registrar: DIRECTI INTERNET SOLUTIONS PVT. LTD. D/B/A PUBLICDOMAINREGISTRY.COM
   Whois Server: whois.PublicDomainRegistry.com
   Referral URL: http://www.PublicDomainRegistry.com

   Server Name: GOOGLE.COM.TW
   Registrar: WEB COMMERCE COMMUNICATIONS LIMITED DBA WEBNIC.CC
   Whois Server: whois.webnic.cc
   Referral URL: http://www.webnic.cc

   Server Name: GOOGLE.COM.TR
   Registrar: DIRECTI INTERNET SOLUTIONS PVT. LTD. D/B/A PUBLICDOMAINREGISTRY.COM
   Whois Server: whois.PublicDomainRegistry.com
   Referral URL: http://www.PublicDomainRegistry.com

   Server Name: GOOGLE.COM.SUCKS.FIND.CRACKZ.WITH.SEARCH.GULLI.COM
   IP Address: 80.190.192.24
   Registrar: EPAG DOMAINSERVICES GMBH
   Whois Server: whois.enterprice.net
   Referral URL: http://www.enterprice.net

   Server Name: GOOGLE.COM.SPROSIUYANDEKSA.RU
   Registrar: MELBOURNE IT, LTD. D/B/A INTERNET NAMES WORLDWIDE
   Whois Server: whois.melbourneit.com
   Referral URL: http://www.melbourneit.com

   Server Name: GOOGLE.COM.SERVES.PR0N.FOR.ALLIYAH.NET
   IP Address: 84.255.209.69
   Registrar: GODADDY.COM, INC.
   Whois Server: whois.godaddy.com
   Referral URL: http://registrar.godaddy.com

   Server Name: GOOGLE.COM.SA
   Registrar: OMNIS NETWORK, LLC
   Whois Server: whois.omnis.com
   Referral URL: http://domains.omnis.com

   Server Name: GOOGLE.COM.PLZ.GIVE.A.PR8.TO.AUDIOTRACKER.NET
   IP Address: 213.251.184.30
   Registrar: OVH
   Whois Server: whois.ovh.com
   Referral URL: http://www.ovh.com

   Server Name: GOOGLE.COM.MX
   Registrar: DIRECTI INTERNET SOLUTIONS PVT. LTD. D/B/A PUBLICDOMAINREGISTRY.COM
   Whois Server: whois.PublicDomainRegistry.com
   Referral URL: http://www.PublicDomainRegistry.com

   Server Name: GOOGLE.COM.IS.NOT.HOSTED.BY.ACTIVEDOMAINDNS.NET
   IP Address: 217.148.161.5
   Registrar: ENOM, INC.
   Whois Server: whois.enom.com
   Referral URL: http://www.enom.com

   Server Name: GOOGLE.COM.IS.HOSTED.ON.PROFITHOSTING.NET
   IP Address: 66.49.213.213
   Registrar: NAME.COM LLC
   Whois Server: whois.name.com
   Referral URL: http://www.name.com

   Server Name: GOOGLE.COM.IS.APPROVED.BY.NUMEA.COM
   IP Address: 213.228.0.43
   Registrar: GANDI SAS
   Whois Server: whois.gandi.net
   Referral URL: http://www.gandi.net

   Server Name: GOOGLE.COM.HAS.LESS.FREE.PORN.IN.ITS.SEARCH.ENGINE.THAN.SECZY.COM
   IP Address: 209.187.114.130
   Registrar: TUCOWS INC.
   Whois Server: whois.tucows.com
   Referral URL: http://domainhelp.opensrs.net

   Server Name: GOOGLE.COM.DO
   Registrar: GODADDY.COM, INC.
   Whois Server: whois.godaddy.com
   Referral URL: http://registrar.godaddy.com

   Server Name: GOOGLE.COM.COLLEGELEARNER.COM
   IP Address: 72.14.207.99
   IP Address: 64.233.187.99
   IP Address: 64.233.167.99
   Registrar: GODADDY.COM, INC.
   Whois Server: whois.godaddy.com
   Referral URL: http://registrar.godaddy.com

   Server Name: GOOGLE.COM.CO
   Registrar: NAMESECURE.COM
   Whois Server: whois.namesecure.com
   Referral URL: http://www.namesecure.com

   Server Name: GOOGLE.COM.BR
   Registrar: ENOM, INC.
   Whois Server: whois.enom.com
   Referral URL: http://www.enom.com

   Server Name: GOOGLE.COM.BEYONDWHOIS.COM
   IP Address: 203.36.226.2
   Registrar: TUCOWS INC.
   Whois Server: whois.tucows.com
   Referral URL: http://domainhelp.opensrs.net

   Server Name: GOOGLE.COM.AU
   Registrar: PLANETDOMAIN PTY LTD.
   Whois Server: whois.planetdomain.com
   Referral URL: http://www.planetdomain.com

   Server Name: GOOGLE.COM.ACQUIRED.BY.CALITEC.NET
   IP Address: 85.190.27.2
   Registrar: ENOM, INC.
   Whois Server: whois.enom.com
   Referral URL: http://www.enom.com

   Domain Name: GOOGLE.COM
   Registrar: MARKMONITOR INC.
   Whois Server: whois.markmonitor.com
   Referral URL: http://www.markmonitor.com
   Name Server: NS1.GOOGLE.COM
   Name Server: NS2.GOOGLE.COM
   Name Server: NS3.GOOGLE.COM
   Name Server: NS4.GOOGLE.COM
   Status: clientDeleteProhibited
   Status: clientTransferProhibited
   Status: clientUpdateProhibited
   Status: serverDeleteProhibited
   Status: serverTransferProhibited
   Status: serverUpdateProhibited
   Updated Date: 18-nov-2008
   Creation Date: 15-sep-1997
   Expiration Date: 14-sep-2011

>>> Last update of whois database: Sat, 21 Feb 2009 06:40:13 EST <<<

NOTICE: The expiration date displayed in this record is the date the
registrar's sponsorship of the domain name registration in the registry is
currently set to expire. This date does not necessarily reflect the expiration
date of the domain name registrant's agreement with the sponsoring
registrar. Users may consult the sponsoring registrar's Whois database to
view the registrar's reported date of expiration for this registration.

TERMS OF USE: You are not authorized to access or query our Whois
database through the use of electronic processes that are high-volume and
automated except as reasonably necessary to register domain names or
modify existing registrations; the Data in VeriSign Global Registry
Services' ("VeriSign") Whois database is provided by VeriSign for
information purposes only, and to assist persons in obtaining information
about or related to a domain name registration record. VeriSign does not
guarantee its accuracy. By submitting a Whois query, you agree to abide
by the following terms of use: You agree that you may use this Data only
for lawful purposes and that under no circumstances will you use this Data
to: (1) allow, enable, or otherwise support the transmission of mass
unsolicited, commercial advertising or solicitations via e-mail, telephone,
or facsimile; or (2) enable high volume, automated, electronic processes
that apply to VeriSign (or its computer systems). The compilation,
repackaging, dissemination or other use of this Data is expressly
prohibited without the prior written consent of VeriSign. You agree not to
use electronic processes that are automated and high-volume to access or
query the Whois database except as reasonably necessary to register
domain names or modify existing registrations. VeriSign reserves the right
to restrict your access to the Whois database in its sole discretion to ensure
operational stability. VeriSign may restrict or terminate your access to the
Whois database for failure to abide by these terms of use. VeriSign
reserves the right to modify these terms at any time.

The Registry database contains ONLY .COM, .NET, .EDU domains and
Registrars.
-----------------------------------------------------------------------
MarkMonitor, the Global Leader in Enterprise Brand Protection

Domain Management
Online Trademark Protection
Online Channel Protection
AntiPhishing Solutions
-----------------------------------------------------------------------
The Data in MarkMonitor.com's WHOIS database is provided by MarkMonitor.com
for information purposes, and to assist persons in obtaining information
about or related to a domain name registration record. MarkMonitor.com
does not guarantee its accuracy. By submitting a WHOIS query, you agree
that you will use this Data only for lawful purposes and that, under no
circumstances will you use this Data to: (1) allow, enable, or otherwise
support the transmission of mass unsolicited, commercial advertising or
solicitations via e-mail (spam); or (2) enable high volume, automated,
electronic processes that apply to MarkMonitor.com (or its systems).
MarkMonitor.com reserves the right to modify these terms at any time.
By submitting this query, you agree to abide by this policy.

Registrant:
        Dns Admin
        Google Inc.
        Please contact <email address hidden> 1600 Amphitheatre Parkway
         Mountain View CA 94043
        US
        <email address hidden> +1.6502530000 Fax: +1.6506188571

    Domain Name: google.com

        Registrar Name: Markmonitor.com
        Registrar Whois: whois.markmonitor.com
        Registrar Homepage: http://www.markmonitor.com

    Administrative Contact:
        DNS Admin
        Google Inc.
        1600 Amphitheatre Parkway
         Mountain View CA 94043
        US
        <email address hidden> +1.6506234000 Fax: +1.6506188571
    Technical Contact, Zone Contact:
        DNS Admin
        Google Inc.
        2400 E. Bayshore Pkwy
         Mountain View CA 94043
        US
        <email address hidden> +1.6503300100 Fax: +1.6506181499

    Created on..............: 1997-09-15.
    Expires on..............: 2011-09-13.
    Record last updated on..: 2008-06-08.

    Domain servers in listed order:

    ns1.google.com
    ns3.google.com
    ns4.google.com
    ns2.google.com

-----------------------------------------------------------------------
MarkMonitor, the Global Leader in Enterprise Brand Protection

Domain Management
Online Trademark Protection
Online Channel Protection
AntiPhishing Solutions
-----------------------------------------------------------------------
--
bhavani@hardy:~$

Revision history for this message
Tom (tom6) said :
#4

Wow, brilliant Bhavani :)

Revision history for this message
Master (master-4-master) said :
#5

Really Brilliant answer Bhavani :)
I checked several options but this was remain.

Currently I am out of my office so I can't check this solution and tomorrow is Sunday. So I will check it on monday.

But I am still not sure for this; because
For Using "whois" I require a domain/website name that is registered to somewhere. My GatewayServer is somewhere registered that I know. But I don't know it's DNS name so how to fire whois command. Because for internet we use DHCP settings; so every thing is assigned automatically. I can find out the Gateways External IP by surfing webs that tells IP address; but still the problem is how to find it through Terminal.

Lets Make it more simple and clear; if I can access my Gateway's Terminal for firing commands then is it possible? I don't have any other access except the Gateway's terminal.

I also tried with "Netstat" command on Gateway's Terminal. It shows all the hosts(Internal & External) connected to the server. Shows IP of all other HOSTs but does not show it's own External IP.

I also didn't check "who am I" so I am going to try both "whois" and "who am I" on monday.

Any other solution ????
Yes! I have the access for Gateway's terminal. I know Gateway with some 192.168.xx.xx; nothing else.

Revision history for this message
Best Deapesh (deapesh) said :
#6

have you tried: wget -U "" http://www.ip-adress.com to get the html file?

Revision history for this message
Master (master-4-master) said :
#7

Thanks Deapesh, that solved my question.

Revision history for this message
rajasthani (chococream52) said :
#8

Use the following command to get your external ip address :

wget http://Www.whatismyip.com -O - -o /dev/null | grep '<TITLE>' | sed -r 's/<TITLE>WhatIsMyIP\.com \- //g' | sed -r 's/<\/TITLE>//g'

OR

wget http://www.ip-details.com/ -O - -o /dev/null | grep '<TITLE>' | sed -r 's/<TITLE>Ip-details\.com \- //g' | sed -r 's/<\/TITLE>//g'