inetipinfo – is a script, that will find/return your internet ip address on a linux machine

After searching for a program or a script for my linux distribution, that will give me my Internet ip address, i didn’t find

any. So I decided to write my own script, that has been tested and works. You can either copy the code from here, or a better

way is to download the package from the link below, and install it.


### inetinfo
## inetinfo is a script, that will return your internet ip address on a linux machine.
## The script was written by Robert Mileski.
## You can contact the author for any suggestions or report bugs at the following email:

# Copyright (C) 2008
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

function message {
echo “Usage: `basename $0` [-n]”
echo “Outputs your internet IP address.”
echo “”
echo “Options:”
echo ” -n, –no-text : returns only the IP address without text”
echo ” -h, –help : show this usage message”
echo “”
echo “Mail bug reports and suggestions to Robert Mileski .”

function get_ip {
my_ip=`wget -q -O – | grep -E ‘(^|[\>])[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*([\<]|$)’ | sed

-e ‘s/<p>//’ -e ‘s/<b>//’ -e ‘s/<\/b>//’`

function exec_get_ip {
if [ -z $my_ip ]; then
exit 1
echo $my_ip

wget_check=`which wget`

if [ $# -gt 1 ]; then

if [ -z $wget_check ]; then
echo “You must have the wget package to use this script. Please first install wget.”
exit 1

if [ $# -eq “$NO_ARGS” ]; then
if [ -z $my_ip ]; then
echo “No connection to the Internet”
exit 1
echo “Your Internet IP address is: $my_ip”
exit 0

while getopts “nh-:” Option
case $Option in
h) message;;
n) exec_get_ip;;
-) case $OPTARG in
help) message;;
no-text) exec_get_ip;;
*) message;;
*) message
exit $E_OPTERROR;;

Don’t forget to make the file executable with chmod +x name

You can also download the whole installable script from this link:
Just extract the file, and run sudo make install

Best regards,
Robert Mileski


7 Responses to inetipinfo – is a script, that will find/return your internet ip address on a linux machine

  1. vbcode2008 says:

    great, thanks for u’r script

  2. mileski says:

    No problem, glad to be of help.

  3. lwk says:

    Great script, exactly what I was looking for …

  4. Spot on with this write-up, I truly believe this amazing site needs a great deal more attention.
    I’ll probably be returning to read more, thanks for the info!

  5. Ahaa, its pleasant conversation on the topic of this paragraph at this place at this
    website, I have read all that, so now me also commenting here.

  6. safety says:

    Take the supplements that will undoubtedly give
    you the results your money is worth! The extra carbs of the body will certainly be become fat deposits by citrate lyase.

  7. Hello There. I found your blog using msn. This is a
    really well written article. I will be sude to bookmark it and come back to read
    more of your useful info. Thanks for the post. I’ll definitely comeback.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: