online prescription solutions
online discount medstore
pills online
buy lorazepam without prescription
xanax for sale
buy xanax without prescription
buy ambien without prescription
ambien for sale
buy modafinil without prescription
buy phentermine without prescription
modafinil for sale
phentermine for sale
lorazepam for sale
buy lexotan without prescription
bromazepam for sale
xenical for sale
buy stilnox without prescription
valium for sale
buy prosom without prescription
buy mefenorex without prescription
buy sildenafil citrate without prescription
buy adipex-p without prescription
librium for sale
buy restoril without prescription
buy halazepam without prescription
cephalexin for sale
buy zoloft without prescription
buy renova without prescription
renova for sale
terbinafine for sale
dalmane for sale
buy lormetazepam without prescription
nobrium for sale
buy klonopin without prescription
priligy dapoxetine for sale
buy prednisone without prescription
buy aleram without prescription
buy flomax without prescription
imovane for sale
adipex-p for sale
buy niravam without prescription
seroquel for sale
carisoprodol for sale
buy deltasone without prescription
buy diazepam without prescription
zopiclone for sale
buy imitrex without prescription
testosterone anadoil for sale
buy provigil without prescription
sonata for sale
nimetazepam for sale
buy temazepam without prescription
buy xenical without prescription
buy famvir without prescription
buy seroquel without prescription
rivotril for sale
acyclovir for sale
loprazolam for sale
buy nimetazepam without prescription
buy prozac without prescription
mogadon for sale
viagra for sale
buy valium without prescription
lamisil for sale
camazepam for sale
zithromax for sale
buy clobazam without prescription
buy diflucan without prescription
modalert for sale
diflucan for sale
buy alertec without prescription
buy zyban without prescription
buy serax without prescription
buy medazepam without prescription
buy imovane without prescription
mefenorex for sale
lormetazepam for sale
prednisone for sale
ativan for sale
buy alprazolam without prescription
buy camazepam without prescription
buy nobrium without prescription
mazindol for sale
buy mazindol without prescription
buy mogadon without prescription
buy terbinafine without prescription
diazepam for sale
buy topamax without prescription
cialis for sale
buy tafil-xanor without prescription
buy librium without prescription
buy zithromax without prescription
retin-a for sale
buy lunesta without prescription
serax for sale
restoril for sale
stilnox for sale
lamotrigine for sale

Linux: How do you find out what your server’s outgoing ip is?


There are many times when I needed to find out my outgoing (or external) IP for the servers which are behind load balancers or firewalls.  I used to just login to another external server from the server in question and find out by looking at “who” what my external ip is.  Even though it works and I am so used to it, today I decided to figure out a more graceful way of finding my outgoing ip.  As most of us already know, whatismyip.com is the quickest way to find out your outgoing ip from the browser.  So I decided to use the same way on the servers.  So I issued a wget:

wget http://www.whatismyip.org

Well that does the trick.  But being lazy as I am, I did not want to have to cat the output file to find out the ip (plus there is no point of creating extra files and doing extra work to remove them).  So if you are ssh’ed in, you can issue following command (I am sure there is another way of doing it, but this is the quickest way I could think of):

wget -q -O - http://www.whatismyip.org

-O tells wget to redirect output to the following file (- being the standard out ).  So it basically echo’s output to our console.

-q makes wget run in  quiet mode so you do not see all of the connection/download/etc output.

That is it!  I am curious to know what other ways people use to get the same information.  Please share your way if possible.

————————————-

DISCLAIMER: Please be smart and use code found on internet carefully. Make backups often. And yeah.. last but not least.. I am not responsible for any damage caused by this posting. Use at your own risk.


10 Responses to “ Linux: How do you find out what your server’s outgoing ip is? ”

  1. September 4th, 2008 | 9:09 am

    Try wget http://www.whatismyip.org. It returns just the IP, just like the n09230945.asp example above. A little easier to remember too… =)

  2. September 4th, 2008 | 9:18 am

    Thats a very useful url to remember. One small simplification though, you can replace ‘$SSH_TTY’ with ‘-’ to send directly to standard out.

  3. September 4th, 2008 | 9:18 am

    Thanks jaredmellentine! I have updated the post with “org” url.

  4. September 4th, 2008 | 9:25 am

    Alex: thanks for your tip. I have updated the post to reflect your recommendation.

  5. September 5th, 2008 | 2:28 pm

    why wouldn’t you use /sbin/ifconfig eth0

  6. September 5th, 2008 | 4:26 pm

    Because when you are behind firewall/load balancers, you tend to have private IPs. Most businesses with multiple servers will have it setup that way so they don’t have to buy/justify big blocks of IPs.

  7. October 14th, 2008 | 2:57 pm

    Though it’s basically the same thing, I have always used
    ‘curl whatismyip.org’
    which defaults to having no extra verbosity while outputting to stdout.

  8. silvertip257
    May 14th, 2009 | 10:15 am

    I use the following code for my own external IP script (used with Torsmo/Conky).

    wget -q -O – http://www.whatismyip.com/automation/n09230945.asp
    # basically the automation page
    # that someone else mentioned in an earlier comment
    # saves bandwidth!

    For sometime, there was actually a complaint message posted on WhatIsMyIP.com’s website … it linked to the automation page and requested that scripts have a reasonable hit frequency (NOT every two minutes or less … more like 30 minutes to an hour or more). I know for example my dynamic IP at home does not change for months and the DDNS script on my router does not try to update my IP on DynDNS all that often either.

    People need to think before they code (even pseudocode first) and test the code … and when networks are involved use tcpdump or Wireshark to verify how much network traffic you are creating!

  9. June 13th, 2009 | 9:24 pm

    I used to use whatismyip, but the html gets annoying, so I created http://ip.admiralsananda.net – it’s just a simple perl script:

    $ cat ip.pl
    #!/usr/bin/perl

    print “Content-type: text/plain; charset=iso-8859-1\n\n”;
    print “$ENV{‘REMOTE_ADDR’}”;
    print “\n\n”;

    It’s useful to have this script (or something similar) because then you can use the output in bash scripts without tons of sanitization/parsing

  10. July 5th, 2014 | 12:00 pm

    Hi, constantly i used to check blog posts here in the early hours in the morning, since
    i enjoy to gain knowledge of more and more.

    Feel free to visit my blog post; testosterone cap

Leave a reply

*
To prove that you're not a bot, enter this code
Anti-Spam Image