🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.sys.sgi.admin
2 messages
2 total messages Started by Andrew Cherenson Tue, 15 Dec 1992 02:17
Re: system names from IP
#9
Author: Andrew Cherenson
Date: Tue, 15 Dec 1992 02:17
37 lines
1524 bytes
In article <JACKR.92Dec14175813@dblues.wpd.sgi.com> jackr@wpd.sgi.com (John "Jack" Repenning) writes:
>In article <1992Dec14.172453.26933@den.mmc.com> beck@enterprise.den.mmc.com (Fred R. Beck) writes:
>
>   Has anyone out there ever tried to resolve a system name
>   from an IP number?
>
>It turns out to be even easier than one other responder suggests.
>I've never seen documentation that admits this (so it's probably
>totally unofficial), but every version of nslookup I've ever tried
>will accept:
>
>	nslookup <<EOF
>	set q=ptr
>	$1
>	EOF
>
>That is, you don't need the shell-game to reverse the address and add
>"in-addr.arpa".

nslookup takes command-line options. For example,

    % nslookup -q=ptr 192.48.153.1
    Server:  sgi
    Address:  0.0.0.0

    1.153.48.192.in-addr.arpa       name = SGI.COM

When using nslookup on IRIX and other systems using BIND 4.8.3, nslookup
treates IP addresses specially when the query type is A (the default).
For example:

    % nslookup 192.48.153.1
    Server:  sgi
    Address:  0.0.0.0

    Name:    SGI.COM
    Address:  192.48.153.1
Re: system names from IP
#10
Author: Sam Fulcomer
Date: Tue, 15 Dec 1992 02:49
94 lines
2467 bytes
In article <tk0qf9s@sgi.sgi.com> arc@xingping.esd.sgi.com (Andrew Cherenson) writes:
>>
>>That is, you don't need the shell-game to reverse the address and add
>>"in-addr.arpa".
>
>nslookup takes command-line options. For example,
>

some do, some don't. This is what I use now (I fancied up the other
script to use as an example sh script for our users)...


#!/bin/sh  

# if you want this to run under ultrix change to "#!/bin/sh5" (bleechh...)

###################### VARIABLES
TRUE=0
FALSE=1
VERBOSE=$FALSE

###################### ROUTINES
		     # remember to pass all arguments
lookit_up() {		
	revaddr=`echo $1 | awk -F. '{printf("%s.%s.%s.%s\n",$4,$3,$2,$1)}'  `
        nslookup <<%% | grep ${revaddr}.in-addr.arpa | awk '{print $NF}'
        set query=ptr
        ${revaddr}.in-addr.arpa
%%
}

print_hostname() {
    if test $VERBOSE -eq $TRUE
    then
	echo $1 = `lookit_up $1 `
    else
	lookit_up $1
    fi
}

printusage() {				# $0 is still the script name...
cat <<%%  

    usage: 	$0 [ -v ] [address...]

    $0 looks up a hostname for each address specified,
    or with no arguments, reads standard input for addresses until EOF.

        -v    Display result as "address = hostname"
%%
}

main() {				# this is here cuz sh doesn't "goto"
if test "$#" -eq 0 			# input is stdin	
then
    while read i
    do
	print_hostname $i
    done
else					# cmd line args...
    case "$1" in
	-h)
	    printusage >&2		# to stderr
	    exit
	    ;;
	-v)
            VERBOSE=$TRUE
            shift
	    main $*			# we'd like "goto" here...
	    exit 
            ;;
	 *)
	    ;;
	
    esac

    while test $# -ge 1
    do
	print_hostname $1
	shift
    done
fi
}

### do the work

main $*

		# There are a number of ways achieving the result of the
		# recursion, however I'd prefer the non-exisitent "goto",
		# so recursion seems the suitably perverse alternative.
-- 
_/**/Sam_Fulcomer	sgf@cfm.brown.edu	What, me panic: uba crazy
Brown University  Center for Fluid Mechanics, Turbulence  and Computation
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads