Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Get IP info with Linux command
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Get IP info with Linux command

This gets the local host's public IP info:

$ curl -L q.dynaip.net

{"timezone":"America\/New_York","isp":"Lightstream Transmission and Telecom Inc","region_code":"GA","country":"United States","dma_code":"0","area_code":"0","region":"Georgia","ip":"199.233..","asn":"AS7363","continent_code":"NA","city":"Atlanta","postal_code":"30303","longitude":-84.3915,"latitude":33.7516,"country_code":"US","country_code3":"USA"}

This gets any IP info you want, for example, 8.8.4.4,

$ curl -L q.dynaip.net/8.8.4.4

{"country":"United States","dma_code":"0","area_code":"0","ip":"8.8.4.4","asn":"AS15169","continent_code":"NA","isp":"Google Inc.","longitude":-97,"latitude":38,"country_code":"US","country_code3":"USA"}

Maybe you somebody else has known that, but I found it's useful for me. :p

Comments

  • I prefer curl getipaddr.net

    Thanked by 1black
  • howardsl2howardsl2 Member
    edited January 2014

    I use dig +short myip.opendns.com @resolver1.opendns.com in my auto IP update script.

    I just wrote a related blog article at http://bit.ly/1cPd7Lw. You can also click on my signature. Anyone interested in automatically updating their VPS' Public IPs upon deployment (for example on Amazon EC2 or DigitalOcean) are welcome to take a look.

    Edit: I may have misunderstood the OP's question... My method was for getting one's public IP.

  • I prefer

    curl http://ipecho.net/plain

  • skagerrakskagerrak Member
    edited January 2014

    I guess people here are talking about different things. Afaik the OP doesn't simply want to see his public facing IP, but instead get some more detailed information about the IP itself (as posted).

    If you just want to get your public IP without relying on external services a ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'should do the trick. (This is interface independent.)

  • curl ifconfig.me

  • tuxtux Member

    @skagerrak said:
    If you just want to get your public IP without relying on external services a ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'should do the trick. (This is interface independent.)

    If you are inside NAT, you see your private ip(s) when you use this command.

    tux@g6:~$ ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }'
    lo: 127.0.0.1
    wlan0: 10.0.0.11
  • NeoonNeoon Community Contributor, Veteran
Sign In or Register to comment.