name server

Paul Pomes - UofIllinois CSO paul at uxc.cso.uiuc.edu
Tue Sep 11 03:45:33 AEST 1990


Thomas Dwyer III <TOMIII at MTUS5.BITNET> writes:

>Does anyone know how to obtain the hostname of a machine given the IP
>address using a name server (the nslookup feature of unix?) ?
>
>Thanks,
>Thomas Dwyer III                        Email: tomiii at mtu.edu
>Network Programmer                             tomiii at mtus5.BITNET
>Computing Technology Services           Voice: (906) 487-2110
>Michigan Technological University       Fax:   (906) 487-2787

Try these csh aliases (courtesy of Matt Crawford):

# BIND aliases
alias a		"(" echo set q=A ";" echo \!\* ")" "|" nslookup
alias cname	"(" echo set q=CNAME ";" echo \!\* ")" "|" nslookup
alias mx	"(" echo set q=MX ";" echo \!\* ")" "|" nslookup
alias hinfo	"(" echo set q=HINFO ";" echo \!\* ")" "|" nslookup
alias ns	"(" echo set q=NS ";" echo \!\* ")" "|" nslookup
alias any	"(" echo set q=ANY ";" echo \!\* ")" "|" nslookup
alias soa	"(" echo set q=SOA ";" echo \!\* ")" "|" nslookup
alias ptr	echo \!$ \| awk -F. \'\{printf \"set q=PTR\\n%s.%s.%s.%s.in-addr.arpa\\n\",\$4,\$3,\$2,\$1\}\' \| nslookup

or these ksh functions:

# BIND functions

function a	# Addresses
{
	nslookup <<- EOF
	set q=A
	$1
	EOF
}

function cname	# Canonical name
{
	nslookup <<- EOF
	set q=CNAME
	$1
	EOF
}

function mx	# Mail eXchangers
{
	nslookup <<- EOF
	set q=MX
	$1
	EOF
}

function hinfo	# Host information
{
	nslookup <<- EOF
	set q=HINFO
	$1
	EOF
}

function ns	# Name servers
{
	nslookup <<- EOF
	set q=NS
	$1
	EOF
}

function any	# Any query
{
	nslookup <<- EOF
	set q=ANY
	$1
	EOF
}

function soa	# Start of authority
{
	nslookup <<- EOF
	set q=SOA
	$1
	EOF
}

function ptr	# Inverse query
{
	print $1 | awk -F. '{printf "set q=PTR\n%s.%s.%s.%s.in-addr.arpa\n",$4,$3,$2,$1}' | nslookup
}
--
         Paul Pomes

UUCP: {att,iuvax,uunet}!uiucuxc!paul   Internet, BITNET: paul at uxc.cso.uiuc.edu
US Mail:  UofIllinois, CSO, 1304 W Springfield Ave, Urbana, IL  61801-2910



More information about the Comp.unix.questions mailing list