Brendon Crawford

Practical Approaches to Software

2010-11-20

4 Ways to Get an IP Address From a Host Name in Shell/Bash

$ dig +short google.com A | head -n1

$ host -4t A google.com | head -n1 | awk -F' ' '{print $NF}'

$ gethostip google.com | cut -d' ' -f2

$ nslookup google.com | grep -iFA2 'Non-authoritative answer:' | grep -iF 'Address:' | cut -d' ' -f2
Posted by Brendon at 11/20/2010 05:01:00 PM 0 comments Links to this post
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Archive

  • ►  2011 (6)
    • ►  Sep (2)
      • Fixing the DropBox Client for GNU/Linux
      • Installing Erlang and Agner Package Manager from S...
    • ►  Aug (1)
      • Installing RabbitMQ with Management Plugin from So...
    • ►  Jul (1)
      • Sharing a Terminal Session Between 2 Users Behind ...
    • ►  May (1)
      • Shell Scripting with GNU Screen
    • ►  Jan (1)
      • Compiling Nginx from Source on Ubuntu 10.04
  • ▼  2010 (1)
    • ▼  Nov (1)
      • 4 Ways to Get an IP Address From a Host Name in Sh...
  • ►  2009 (6)
    • ►  Nov (2)
      • DrupalORM: As a programmatic ORM interface to node...
      • Fixing Weak Wireless on Asus EEE PC With Ubuntu 9....
    • ►  Aug (2)
      • Write to HFSPlus Formatted iPod From Linux (Ubuntu...
      • Enabling Memory Profiling for xDebug 2
    • ►  Jul (1)
      • Using GnuCash With Bank of the West
    • ►  Apr (1)
      • Theming the Drupal 6 User Login Form
  • ►  2008 (3)
    • ►  Jul (1)
      • Drupy: Drupal in Python
    • ►  Apr (1)
      • Drupal AJAX Forms Validation
    • ►  Mar (1)
      • Get Non Up-to-Date Files in CVS
  • ►  2007 (1)
    • ►  Oct (1)
      • Enabling CakePHP 1.1 on Lighttpd 1.5
Simple template. Powered by Blogger.