#!/bin/ksh ## ## SCRIPT NAME: prtplt_sho_dns_hosts_IPdupes ## ## Where : in $FEDIR/scripts where FEDIR=/apps/nns_com/fea ## ############################################################################## ## PURPOSE: Uses 'nslookup' 'ls' command to get a sorted list of NNS hosts ## (and various non-printer & printer DNS devices) --- to ## sort by IP-address, rather than by-device-name. ## ## Then uses 'uniq -d' to extract only the duplicate IP addresses. ## ## See 'prtplt_sho_dns_hosts_IPsort' for sort by-IP-address. ## See 'prtplt_sho_dns_hosts' for sort by-name. ## ## NOTE: This utility shows devices in nns.com domain, but NOT in ## prt.nns.com domain. ## Starting in mid-2000, printers started showing up in the nns.com ## domain instead of the prt.nns.com domain, as DHCP was being ## implemented to recognize printer definitions. ############################################################################## ## CALLED BY: $FEDIR/scripts/prtplt_mgr -> ## $FEDIR/tkGUIs/prtplt_lists ## ## where $FEDIR/scripts/prtplt_mgr is called by 'handytools' command, ## $FEDIR/scripts/handytools -- actually by ## $FEDIR/scripts/handytools.chestdef ## ## and also by the 'screentools' command, $FEDIR/scripts/screentools ## --- actually by $FEDIR/scripts/screentools.chestdef. ## ## Can also be called user $HOME/.auxchestrc files. Example: ## /usr/people/bmo01/.auxchestrc. ## ## Could also be a desktop icon, created by 'Find, File QuickFind' on ## SGI Toolchest. ############################################################################## ## MAINTENANCE HISTORY: ## Written by: Blaise Montandon 9mar2001 Based on ## 'prtplt_sho_dns_hosts_IPsort' ## in $FEDIR/scripts ## Updated by: Blaise Montandon 9mar2001 ############################################################################## if test "$FEDIR" = "" then FEDIR=/apps/nns_com/fea fi ############################################################################## ## WARN USER THAT THIS QUERY WILL TAKE ABOUT 10 SECONDS. ## (I.e. the next popup will be in about 10 secs.) ############################################################################## xconfirm -c -B DISMISS \ -t "This ALL-DNS-devices query will take about 10 secs to complete." \ -font -*-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ > /dev/null & # -font -adobe-courier-bold-r-normal-*-14-*-*-*-*-*-*-* \ ############################################################################## ## PREP THE NAMES OF THE LIST FILE (AND AN INTERMEDIATE FILE). ############################################################################## . $FEDIR/scripts/set_localoutlist OUTLIST2=${OUTLIST}_2 ############################################################################## ## PREP THE TOP OF THE LIST (A HEADING). ############################################################################## echo "\ ****************** `date '+%Y %b %d %a %T%p %Z'` *************************** HOST MACHINES (& other devices, like routers and printers) on the NNS NETWORK, in the 'nns.com' domain ************************************ *** WITH DUPLICATE IP-ADDRESSES **** ************************************ -- according to NNS DNS (Domain Name Service), via the 'nslookup' command. Performed on host: `hostname` SORTED BY *IP-ADDRESS*. A description of this list is at the bottom of the list. ------------------------------------------------------------------------ " > $OUTLIST2 ############################################################################## ## GATHER THE LIST CONTENTS -- with nslookup. ############################################################################## ## 'man nslookup' shows: ## ## ls [option] domain [> filename] ## ls [option] domain [>> filename] ## List the information available for domain, optionally creating or ## appending to filename. The default output contains host names and ## their Internet addresses. Option can be one of the following: ## ## -t querytype ## lists all records of the specified type (see querytype below). ## ## -a lists aliases of hosts in the domain. synonym for -t CNAME. ## ## ***>> -d lists all records for the domain. synonym for -t ANY. ## ## -h lists CPU and operating system information for the domain. ## synonym for -t HINFO. ## ## -s lists well-known services of hosts in the domain. synonym for ## -t WKS. ## ## When output is directed to a file, hash marks are printed for every ## 50 records received from the server. ## AND: ## querytype=value ## type=value ## Change the type of information query to one of: ## ## A the host's Internet address. ## ## CNAME the canonical name for an alias. ## ## HINFO the host CPU and operating system type. ## ## MINFO the mailbox or mail list information. ## ## MX the mail exchanger. ## ## NS the name server for the named zone. ## ## PTR the host name if the query is an Internet address, ## otherwise the pointer to other information. ## ## SOA the domain's ``start-of-authority'' information. ## ## TXT the text information. ## ## UINFO the user information. ## ## WKS the supported well-known services. ## ## Other types (ANY, AXFR, MB, MD, MF, NULL) are described in the ## RFC-1035 document. ## (Default = A, abbreviations = q, ty) ############################################################################## ## FOR TESTING: # set -x nslookup > $OUTLIST << ENDofINPUT ls -t A nns.com exit ENDofINPUT ############################################################################## ## ONE COULD GENERATE JUST A LIST of ' A ' RECS and 'CNAME ' recs -- ## but the list would be missing the query-type indicators -- A & CNAME. ############################################################################## ## nslookup > $OUTLIST << ENDofINPUT ## ls -t A nns.com ## ls -t CNAME nns.com ## exit ## ENDofINPUT ############################################################################## ############################################################################## ## EXTRACT & SORT THE 'A' RECS LIST. ############################################################################## ## THE 'tail +5' of the EXTRACT eliminates the first 4 records, like: ## ## Default Server: netman4.nns.com ## Address: 172.16.4.203 ## ## > [netman4.nns.com] ############################################################################## ## THE "awk '{print $2}'" of the EXTRACT keeps only the 2nd column info, ## which is usually IP address. ############################################################################## ## THE "grep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*'" of the EXTRACT removes ## 2nd column info like: ## server = netman4.nns.com ############################################################################## ## THE SORT sorts the four '.'-separated fields of the IP address ## numerically. ############################################################################## ## THE 'uniq -d' shows only the IP-addresses that occur more than once. ############################################################################## ## THE 'nl' counts the duplicate IP-addresses. ############################################################################## ## FOR INITIAL DEVELOPMENT: # cat $OUTLIST | nl >> $OUTLIST2 ## A POOR SORT BY IP ADDRESS: # sort -k2b,2b -k1,1 $OUTLIST | nl >> $OUTLIST2 ## A PRETTY DECENT WAY TO ELIMINATE TOP SEVERAL non-'A' RECS: # egrep '^ ' $OUTLIST | sort -k2b,2b -k1,1 | nl >> $OUTLIST2 tail +5 $OUTLIST | egrep '^ ' | \ awk '{print $2}' | \ grep '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | \ sort -t. -k1n,1n -k2n,2n -k3n,3n -k4n,4n | \ uniq -d | nl >> $OUTLIST2 # awk '{printf ("%-15s \n", $2)}' | \ # rm $OUTLIST ## FOR TESTING: # set - ############################################################################## ## PREP THE BOTTOM OF THE LIST (A TRAILER). ############################################################################## echo " ---------------------------------------------------------------------------- INFO IN THIS LIST: This is a list of IP-addresses extracted from many thousands of network device IP-addresses. This list can help identify devices with duplicate IP addresses. (IP = Internet Protocol) You can use this IP-address to find the names of the duplicate devices, in another report that shows all the device-names and their IP-addresses. The device-identifiers are frequently - Unix (or NT) hostnames -- including server-names, like mail-servers or web/proxy-servers -OR- - communications box names, like router names. The device-identifier may be an NNS Unix host name -- like 'iaw###' for SGI IRIX hosts and 'aix###' or 'acw###' for IBM AIX hosts. NT mail-server names are currently (Jun99) of the form 'nnse#'. Note: This list was extracted from an up-to-date image from the NNS 'nns.com' DNS domain -- at the time indicated in the time-stamp at the top of this list. ------------------------------------------------------------------------ PRINTERS: FOR PRINTERS, the device-identifier if often an NNS Telecomid (or an NNS-assigned 'plotter-queue' name). The IP address is actually the IP address of a 'print server' box/card to which the printer is attached. At NNS, a Telecom ID ###### is often used to make a printer 'queue' name for SGI workstations/hosts by prefixing a building name, like B600_P###### (for plot or Postscript or 'rich text' files) and B600_T###### (used for crude text printouts; automatically adds carriage-returns, and a final form feed, to files, which are assumed to be plain text). ------------------------------------------------------------------------ DEVICE DESCRIPTIONS/LOCATIONS: This list does NOT include *descriptions/locations* of each of these devices. If you need HOSTNAME location or model information -- for example, to solve a network problem: Ask a Computer/Network Support person for help, like an SGI, or other Unix, System Administrator (of O05C 'Open Systems' Support). (If you cannot connect to a Computer/Network Support person, you could call 8-HELP to find an appropriate contact for information on an 'nns.com' device.) ----- For some PRINTER location & model information: 0) First, ask colleagues in your area for an appropriate printer/TelcomID to use for your application. or 1) For a given printer identifier, use a LookUp-Queue-info query in SGI utility 'prtplt_mgr'. or 2) Search NT network printer/terminal device lists. or 3) Search a printer list in various SGI print-plot utilities, like 'prtplt_mgr', 'xlphp', 'xlpps', 'iplot', or 'screentools'. or 4) Refer to printer lists/queries at nnsFEAmenu option 'u p h' (Utilities,Print,Help) on an SGI workstation. or 5) Ask a Computer/Network Support person for help, like - a PC-NT Field Administrator (of O05C Open Systems Support), or - an I-DEAS Administrator (of O06 Applications Support), or - an SGI, or other Unix, System Administrator (of O05C Open Systems Support). ------------------------------------------------------------------------ SOURCE OF THIS LIST: This list comes from the NNS DNS (Domain Name Service) via the 'nslookup' command -- applied to domain 'nns.com'. In particular, this list was generated by running the script $0 on host `hostname` . A similar inquiry, with a couple of sort options, is available among the network HOST/DEVICE inquiries & lists at nnsFEAmenu options 'h a1' (Help-general,Architecture-hosts) or 'u n hi' (Utilities,NetVu,Host-IDs) or 'u h hi' (Utilities,HostVu,Host-IDs) In particular, that inquiry is performed by running the script $FEDIR/scripts/sho_dns_hosts . ------------------------------------------------------------------------ UNDER THE COVERS: This list was assembled using the 'nslookup' command with the 'ls -t A' sub-command. Specifically, nslookup > $OUTLIST << ENDofINPUT ls -t A nns.com exit ENDofINPUT followed by an extract (filter) and a re-format and sort and numbering (with 'tail', grep', 'awk', 'sort', 'uniq', 'nl'). For details, see the script $0 For information on the output of 'nslookup', you can type 'man nslookup' in an SGI winterm window. Or you can refer to the 'Man Pages' or 'OnLine Books' (Search option) in the bottom Help drawer of the SGI Toolchest. ********************* END OF LIST OF DEVICE IDENTIFIERS ********************* ************** on the NNS NETWORK, in the 'nns.com' domain ****************** " >> $OUTLIST2 ############################################################################## ## SHOW THE LIST (IN A SCROLLABLE TEXT WINDOW). ############################################################################## $FEDIR/scripts/shofil $OUTLIST2 # export SHOFILENAME="$OUTLIST2" # $FEDIR/tkGUIs/shofil.tk & ## FOR TESTING: # set -