commandlinefu.com is the place to record those command-line gems that you return to again and again.
You can sign-in using OpenID credentials, or register a traditional username and password.
Subscribe to the feed for:
Relies on ifconfig.me functioning. It's about as easy as it gets, and memorable to old geeks too.
has the benefit of being a bit more cross-platform.
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 22.214.171.124 (126.96.36.199), 64 hops max, 52 byte packets
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
Grabs the ip2location site and removes everything but the span tag containing the country value. Place it inside your .bashrc or .bash_aliases file.
Useful for creating MAC addresses for virtual machines on a subnet. 00:16:3e is a standard Xen OID, change as needed.
for those that don't have curl
Very effective, use only DNS protocol. The @ part is optional if you already set opendns servers as default ns servers.
Short command, easy to remember
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 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|
documents all active ips on a subnet and saves to txt file.
Curl is not installed by default on many common distros anymore. wget always is :)
wget -qO- ifconfig.me/ip
Here's a version that uses netcat (although I'd much rather use curl!).
If curl isn't available, use lynx.
With a lolcat favicon if you access it from your browser
Works on any machine with nmap installed. Previous version does not work on machines without "seq".
Also works on subnets of any size.
Extracts ip addressess from file using sed. Uses a tag(ip) to grep the IP lines after extracting. Must be a way to just output regex matched on sed.