
Terminal - Commands tagged ip address - 84 results
wget http://checkip.dyndns.org/ -q -O - | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'
This is sample output - yours may be different.
[v3n0m@localhost]$ wget http://checkip.dyndns.org/ -q -O - | grep -Eo '\<[[:digit:]]{1,3}(\.[[:digit:]]{1,3}){3}\>'
80.254.66.131
[v3n0m@localhost]$
curl http://my-ip.cc/host.json
This is sample output - yours may be different.
{
"host": {
"ipv4": "188.165.241.33",
"hostname": "ns390090.ovh.net",
"address": {
"city":"Roubaix",
"country":"FRANCE (FR)",
"geo": {
"latitude":50.7,
"longitude":3.1667
}
}
}
}
JSON version.
Additionally it may give your geolocation if it's known by hostip.info
curl http://my-ip.cc/host.xml
This is sample output - yours may be different.
<?xml version="1.0" encoding="UTF-8"?>
<host>
<ipv4>188.165.241.33</ipv4>
<hostname>ns390090.ovh.net</hostname>
<address>
<city>Roubaix</city>
<country>FRANCE (FR)</country>
<geo>
<latitude type="float">50.7</latitude>
<longitude type="float">3.1667</longitude>
</geo>
</address>
</host>
XML version.
Additionally it may give your geolocation if it's known by hostip.info
curl http://my-ip.cc/host.txt
This is sample output - yours may be different.
ipv4: 188.165.241.33
hostname: ns390090.ovh.net
city: Roubaix
country: FRANCE (FR)
latitude: 50.7
longitude: 3.1667
Additionally it may give your geolocation if it's known by hostip.info
geoip() { lynx -dump "http://api.hostip.info/get_html.php?ip=$1&position=true"; }
This is sample output - yours may be different.
Country: UNITED STATES (US)
City: Mountain View, CA
Latitude: 37.402
Longitude: -122.078
IP: 74.125.227.48
Defines a function to geolocate a given IP address; if none supplied, will default to your external IP address.
This is sample output - yours may be different.
curl http://ifconfig.me/ip
This is sample output - yours may be different.
$ curl http://ifconfig.me/ip
16.5.61.21
Relies on ifconfig.me functioning. It's about as easy as it gets, and memorable to old geeks too.
getent hosts google.com | awk '{print $1}'
This is sample output - yours may be different.
has the benefit of being a bit more cross-platform.
host google.com|awk '{print $NF}'
This is sample output - yours may be different.
This is sample output - yours may be different.
This is sample output - yours may be different.
host foo.com|grep " has address "|cut -d" " -f4
This is sample output - yours may be different.
Titus:~$ host foo.com|grep "has address "|cut -d" " -f4
64.94.125.138
Get just the IP address for a given hostname. For best results, make this a function in your shell rc file so that it can be used for things like traceroute:
Titus:~$ traceroute `getip foo.com`
traceroute to 64.94.125.138 (64.94.125.138), 64 hops max, 52 byte packets
This is sample output - yours may be different.
$ geoiplookup 74.125.79.99
GeoIP Country Edition: US, United States
$ geoiplookup google.com
GeoIP Country Edition: US, United States
GeoIP Needs to be installed. Can be done from some distro's or via MaxMind.com for free. There even is a free city database availabble. If the GeoLiteCity is downloaded and installed it will also find more information
geoiplookup -f /var/lib/GeoIP/GeoLiteCity.dat commandlinefu.com
GeoIP City Edition, Rev 1: US, NJ, Absecon, 08201, 39.420898, -74.497704, 504, 609
ip2loc() { wget -qO - www.ip2location.com/$1 | grep "<span id=\"dgLookup__ctl2_lblICountry\">" | sed 's/<[^>]*>//g; s/^[\t]*//; s/"/"/g; s/</</g; s/>/>/g; s/&/\&/g'; }
This is sample output - yours may be different.
$ ip2loc 167.4.1.41
UNITED STATES
Grabs the ip2location site and removes everything but the span tag containing the country value. Place it inside your .bashrc or .bash_aliases file.
echo 00:16:3e$(gethostip 10.1.2.11 | awk '{ print tolower(substr($3,3)) }' |sed 's/.\{2\}/:&/g' )
This is sample output - yours may be different.
Useful for creating MAC addresses for virtual machines on a subnet. 00:16:3e is a standard Xen OID, change as needed.
This is sample output - yours may be different.
alternative to
curl ifconfig.me
for those that don't have curl
dig @208.67.222.222 myip.opendns.com
This is sample output - yours may be different.
Very effective, use only DNS protocol. The @ part is optional if you already set opendns servers as default ns servers.
This is sample output - yours may be different.
Short command, easy to remember
wget --quiet -O - checkip.dyndns.org | sed -e 's/[^:]*: //' -e 's/<.*$//'
This is sample output - yours may be different.
Wgets "whatismyip" from checkip.dyndns.org and filters out the actual IP-adress. Usefull when you quickly need to find the outward facting IP-address of your current location.
nmap -v -sP 192.168.0.0/16 10.0.0.0/8
This is sample output - yours may be different.
Starting Nmap 5.21 ( http://nmap.org ) at 2010-07-01 XX:XX EDT
Initiating Ping Scan at XX:XX
Scanning 4096 hosts [2 ports/host]
Completed Ping Scan at XX:XX, 1.50s elapsed (31 total hosts)
Initiating Parallel DNS resolution of 4096 hosts. at XX:XX
Completed Parallel DNS resolution of 4096 hosts. at XX:XX, 0.00s elapsed
Nmap scan report for 10.0.0.1 [host down]
[... snip ...]
Nmap scan report for host1.localdomain (10.0.0.21)
Host is up (0.00031s latency).
Nmap scan report for host2.localdomain (10.0.0.22)
Host is up (0.00041s latency).
Nmap scan report for 10.0.0.23
Host is up (0.00039s latency).
Nmap scan report for host3.localdomain (10.0.0.24)
Host is up (0.00037s latency).
Nmap scan report for 10.0.0.25 [host down]
Nmap scan report for 10.0.0.26 [host down]
Nmap scan report for 10.0.0.27 [host down]
Nmap scan report for host4.localdomain (10.0.0.28)
Host is up (0.0047s latency).
Nmap scan report for 10.0.0.29 [host down]
Nmap scan report for 10.0.0.30 [host down]
Nmap scan report for 10.0.0.31
Host is up (0.0033s latency).
Nmap scan report for 10.0.0.32
Host is up (0.0031s latency).
Nmap scan report for 10.0.0.33 [host down]
Nmap scan report for 10.0.0.34 [host down]
Nmap scan report for 10.0.0.48 [host down]
[... snip ...]
Nmap scan report for 10.0.0.49 [host down]
Nmap scan report for 10.255.255.255 [host down]
Nmap done: 4096 IP addresses (7 hosts up) scanned in XXX seconds
nmap for windows and other platforms is available on developer's site: http://nmap.org/download.html
nmap is robust tool with many options and has various output modes - is the best (imho) tool out there..
from nmap 5.21 man page:
-oN/-oX/-oS/-oG : Output scan in normal, XML, s|
sudo arp-scan -I eth0 192.168.1.0/24
This is sample output - yours may be different.
FOR /L %i IN (1,1,254) DO ping -n 1 10.254.254.%i | FIND /i "Reply">> c:\ipaddresses.txt
This is sample output - yours may be different.
c:\ipadresses.txt:
Reply from 10.254.254.1: bytes=32 time<1ms TTL=255
Reply from 10.254.254.2: bytes=32 time<1ms TTL=255
Reply from 10.254.254.3: bytes=32 time=5ms TTL=255
Reply from 10.254.254.30: bytes=32 time<1ms TTL=128
Reply from 10.254.254.31: bytes=32 time<1ms TTL=128
Reply from 10.254.254.32: bytes=32 time<1ms TTL=128
Reply from 10.254.254.33: bytes=32 time<1ms TTL=128
Reply from 10.254.254.34: bytes=32 time<1ms TTL=128
Reply from 10.254.254.60: bytes=32 time<1ms TTL=64
Reply from 10.254.254.61: bytes=32 time=3ms TTL=60
Reply from 10.254.254.62: bytes=32 time<1ms TTL=64
Reply from 10.254.254.63: bytes=32 time=1ms TTL=64
Reply from 10.254.254.90: bytes=32 time<1ms TTL=128
Reply from 10.254.254.201: bytes=32 time<1ms TTL=128
Reply from 10.254.254.202: bytes=32 time<1ms TTL=128
Reply from 10.254.254.204: bytes=32 time<1ms TTL=128
Reply from 10.254.254.205: bytes=32 time<1ms TTL=128
Reply from 10.254.254.206: bytes=32 time<1ms TTL=128
Reply from 10.254.254.207: bytes=32 time<1ms TTL=128
Reply from 10.254.254.208: bytes=32 time<1ms TTL=128
Reply from 10.254.254.209: bytes=32 time<1ms TTL=128
Reply from 10.254.254.212: bytes=32 time<1ms TTL=128
Reply from 10.254.254.213: bytes=32 time<1ms TTL=128
Reply from 10.254.254.214: bytes=32 time<1ms TTL=128
Reply from 10.254.254.215: bytes=32 time<1ms TTL=128
Reply from 10.254.254.217: bytes=32 time<1ms TTL=64
Reply from 10.254.254.221: bytes=32 time<1ms TTL=128
documents all active ips on a subnet and saves to txt file.
This is sample output - yours may be different.
Curl is not installed by default on many common distros anymore. wget always is :)
wget -qO- ifconfig.me/ip
echo -e "GET /ip HTTP/1.0\nUser-Agent: netcat\nHOST: ifconfig.me\n\n" | nc ifconfig.me 80 | sed -n '/^[0-9]/p'
This is sample output - yours may be different.
Here's a version that uses netcat (although I'd much rather use curl!).
lynx --dump icanhazip.com
This is sample output - yours may be different.
If curl isn't available, use lynx.