[lug] Converting IPs to Domain Names and Vice Versa via Bash
Jeff Schroeder
jeff at neobox.net
Wed Jan 26 16:53:54 MST 2005
Bill asked:
> Does anyone know if there's a simple bash command that can take a
> domain name as input and spit out its IP? Also, can I go the other
> way?
It's not a bash built-in, but you can just use 'ping':
# ping google.com
PING google.com (216.239.39.99): 56 data bytes
To do a reverse lookup, you probably want the 'dig' command (with a -x
argument, for reverse):
# dig -x 216.239.39.99
; <<>> DiG 9.2.3 <<>> -x 216.239.39.99
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 24272
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;99.39.239.216.in-addr.arpa. IN PTR
;; AUTHORITY SECTION:
39.239.216.in-addr.arpa. 60 IN SOA ns1.google.com.
dns-admin.google.com. 2004031201 21600 3600 1038800 60
;; Query time: 306 msec
;; SERVER: 24.221.192.5#53(24.221.192.5)
;; WHEN: Wed Jan 26 16:53:33 2005
;; MSG SIZE rcvd: 104
HTH,
Jeff
More information about the LUG
mailing list