home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / unix / admin / 4928 < prev    next >
Encoding:
Internet Message Format  |  1992-09-08  |  14.9 KB

  1. Path: sparky!uunet!munnari.oz.au!uniwa!craig
  2. From: craig@ec.uwa.oz.au (Craig Richmond - division)
  3. Newsgroups: comp.unix.admin
  4. Subject: Re: Can't get DNS running
  5. Date: 8 Sep 1992 04:13:46 GMT
  6. Organization: The University of Westrn Australia
  7. Lines: 482
  8. Message-ID: <18h99qINN1ju@uniwa.uwa.edu.au>
  9. References: <1992Sep8.123131.164470@dstos3.dsto.gov.au>
  10. NNTP-Posting-Host: decel.ecel.uwa.edu.au
  11.  
  12. gxn@dstos3.dsto.gov.au writes:
  13.  
  14. >Re:- can't get DNS running on a SUN...
  15.  
  16. > I had a similar problem. But reading the Answerbook tells you
  17. >that you have to have NIS running for DNS to work. I.E. all
  18. >calls to the resolver are done via NIS. Therefore you have to
  19. >have NIS running, and initialised with the -b option on the makefile.
  20. >Hope this helps..
  21.  
  22. >Gordon NUSSEY
  23.  
  24. Here is an article that was posted a couple of months back.  It is the
  25. simple instructions for getting DNS to work on your Sun.  Don't mail me for
  26. help, I only archived it.
  27.  
  28. Good Luck,
  29. Craig
  30.  
  31. Path: uniwa!munnari.oz.au!mips!mips!darwin.sura.net!gatech!pitt.edu!apollo!qralston
  32. From: qralston@gl.pitt.edu (James Ralston Crawford)
  33. Newsgroups: comp.sys.sun.admin
  34. Subject: SUMMARY: making Sun DNS hostname resolving work without running NIS
  35. Keywords: Sun DNS resolve resolving NIS name nameserver
  36. Message-ID: <3299@blue.cis.pitt.edu.UUCP>
  37. Date: 18 Jul 92 04:07:28 GMT
  38. Sender: news+@pitt.edu
  39. Reply-To: qralston@gl.pitt.edu
  40. Organization: University of Pittsburgh [CIS]
  41. Lines: 445
  42.  
  43.  
  44.     I received a great number of suggestions and "me-too"s to my
  45. question concerning name resolving without NIS.  I've extrapolated all
  46. of the suggested methods into what (IMHO) works the best.  Read the
  47. "Caveats" and "Parting comments" sections at the end of this, though.
  48.  
  49. Problem:
  50.  
  51.     For whatever reason(s), you're not using NIS on your Sun.
  52. You're relying on a properly configured /etc/resolv.conf(5) (and,
  53. therefore, DNS) to resolve hostnames.  However, utilities such as
  54. nslookup(8c) can resolve hostnames successfully, but any programs that
  55. are dynamically linked (ping, telnet, ftp, etc) will only resolve
  56. hostnames if they are in the /etc/hosts(5) file.
  57.  
  58.  
  59. Quick answer:
  60.  
  61.     As provided by Sun, the resolving routines in /usr/lib/libc.so
  62. don't use DNS to resolve hostnames; they use NIS.
  63.  
  64.  
  65. More detailed answer:
  66.  
  67.     Sun's default resolving routines in /usr/lib/libc.so use a
  68. two-step process to resolve names:
  69.  
  70. 1.  See if the hostname exists in /etc/hosts.
  71. 2.  If that fails, then give the hostname to the NIS server, and let
  72.     it resolve it.
  73.  
  74.     The NIS server then performs these steps:
  75.  
  76. 1.  See if the name exists in /etc/NIS/hosts (or wherever the NIS
  77.     master hosts file is)
  78. 2.  If that fails, and the "B=-b" option was set in /var/yp/Makefile,
  79.     the NIS server will attempt to use DNS to attempt to resolve the
  80.     name.
  81.  
  82.  
  83. Partial solutions:
  84.  
  85. 1.  Give in to Sun's belief that everyone loooooves and uses NIS;
  86.     install NIS; set up an NIS server.
  87.  
  88.     For a lot of people, this is not a practical solution.  Many
  89. organizations are working towards a distributed network, in which each
  90. machine depends on as few as other machines as possible (AFS and DFS
  91. are two prime examples.)  In this case, installing NIS and having all
  92. of your machines depending on one NIS server for resolving hostnames
  93. is taking a step backwards instead of forwards.
  94.  
  95.     In addition, unless the domain name server is also the NIS
  96. server, for hostnames that are not known locally, this makes more work
  97. for the NIS master server, and more network traffic.  (In other words,
  98. hostname resolve requests not known locally would be handled like
  99. this:
  100.  
  101.     localhost -> NIS server -> nameserver
  102.  
  103.     By setting up each machine to use DNS on its own, you
  104. eliminate the middle man (so to speak), and get this:
  105.  
  106.     localhost -> nameserver
  107.  
  108.  
  109. 2.  Replace the resolving routines in /usr/lib/libc.so with the ones
  110.     located in /usr/lib/libresolv.a.
  111.  
  112.     This will make it so that *ALL* hostname resolves will go
  113. directly to DNS, without checking /etc/hosts; the resolving routines
  114. in libresolv.a do not look at /etc/hosts.  (Sun's logic behind this is
  115. that if you're attempting to resolve via DNS, naturally NIS has
  116. already made the attempt to resolve from /etc/NIS/hosts, /etc/hosts,
  117. etc.
  118.  
  119.     Besides having the effect of making your machine rely on DNS
  120. for resolving everything, there are few programs that won't like the
  121. fact that /etc/hosts isn't looked at.  In particular, syslogd will
  122. fail to recognize the machine "loghost" (because this is defined in
  123. the /etc/hosts file.)
  124.  
  125.  
  126. The real (tm) solution:
  127. -----------------------
  128.  
  129.     Throw away Sun's libresolv.a and build a *real* one.  Then
  130. merge those routines into your existing C libraries.  Here's how you
  131. can do this.
  132.  
  133. 1.  Ensure that the "Shlib Custom" optional software category was
  134.     loaded from your SunOS 4.1.x media.
  135.  
  136. 2.  cd to /usr/lib/shlib.etc
  137.  
  138. 3.  su
  139.  
  140. 4.  Copy the file included below to README.DNS in this directory.
  141.  
  142. -----------------------------------------------------------------------
  143. 8<----------/usr/lib/shlib.etc/README.DNS----------cut-here---------->8
  144.  
  145.     This is how to get intelligent DNS resolving in your shared
  146. libc library.  This assumes that you are already familiar with the
  147. procedure outlined in the original README file.
  148.  
  149. Note!  If you are interested in a System V libc, please substitute
  150.         libcs5_pic.a for libc_pic.a in step 6,
  151.         libcs5.so.x.y.z for libc.so.x.y.z in step 17.
  152.  
  153.  
  154. 1.  cd to /usr/lib/shlib.etc and become super user, if you haven't
  155.     already.
  156.  
  157.     $ cd /usr/lib/shlib.etc
  158.     $ su
  159.  
  160.  
  161. 2.  Obtain and unpack the resolv+ package, written by Bill Wisner.
  162.     (It should be available via anonymous ftp from
  163.     hayes.ims.alaska.edu, in the /networking directory.  If it's not,
  164.     then use archie to track a copy down, and tailor the commands
  165.     below as necessary.)
  166.  
  167.     # mkdir resolv+
  168.     # cd resolv+
  169.     # ftp hayes.ims.alaska.edu
  170.     <ftp interaction>
  171.     # /bin/sh resolv+.shar
  172.  
  173.  
  174. 3.  Add the -pic flag to the CFLAGS line in the Makefile for resolv+.
  175.  
  176.     (Additionally, you may have to eliminate the ${DEFS} and -O flags
  177.     and remove the additional ld and mv steps if, in step 14, you get
  178.     this error from ld concerning tmp/gethostnamadr.o:
  179.  
  180.     base relative static symbol(__gethtbyname) botch
  181.  
  182.     Try it first without changing these additional things; if you run
  183.     into problems, then go ahead and change them according to this
  184.     diff):
  185.  
  186.     *** Makefile.orig       Fri Jul 17 03:12:40 1992
  187.     --- Makefile    Fri Jul 17 03:13:16 1992
  188.     ***************
  189.     *** 19,23 ****
  190.             mktemp.o strcasecmp.o strpbrk.o strerror.o
  191.       DEFS= -DDEBUG
  192.     ! CFLAGS=       -O ${DEFS} -Iinclude
  193.       
  194.       libresolv.a: ${OBJS}
  195.     --- 19,23 ----
  196.             mktemp.o strcasecmp.o strpbrk.o strerror.o
  197.       DEFS= -DDEBUG
  198.     ! CFLAGS=       -pic -Iinclude
  199.       
  200.       libresolv.a: ${OBJS}
  201.     ***************
  202.     *** 31,46 ****
  203.       .c.o:
  204.             ${CC} ${CFLAGS} -c $*.c
  205.     -       -ld -x -r $*.o
  206.     -       mv a.out $*.o
  207.       
  208.       gethostnamadr.o: named/gethostnamadr.c
  209.             ${CC} -c ${CFLAGS} named/gethostnamadr.c
  210.     -       -ld -x -r gethostnamadr.o
  211.     -       mv a.out gethostnamadr.o
  212.       
  213.       sethostent.o: named/sethostent.c
  214.             ${CC} -c ${CFLAGS} named/sethostent.c
  215.     -       -ld -x -r sethostent.o
  216.     -       mv a.out sethostent.o
  217.       
  218.       clean: FRC
  219.     --- 31,40 ----
  220.  
  221.  
  222. 4.  Run `make` in the resolv+ directory.  This should give you
  223.     libresolv.a.
  224.  
  225.     # make
  226.     <building messages>
  227.  
  228.  
  229. 5.  Change back to /usr/lib/shlib.etc, and make a temporary directory.
  230.  
  231.     # cd ..
  232.     # mkdir tmp
  233.  
  234.  
  235. 6.  Change to the "tmp" directory just made, extract the contents of
  236.     the libresolv you just built and the pic .o from libc_pic.a (in
  237.     that order!), and rm the file __.SYMDEF.
  238.  
  239.     # cd tmp
  240.     # ar x ../resolv+/libresolv.a
  241.     # ar x ../libc_pic.a
  242.     # rm __.SYMDEF
  243.  
  244.  
  245. 7.  Rename any files that "ar" truncated (grrrrr) to 16 characters to
  246.     their original, proper names.  (The original README file neglects
  247.     to mention the xccs.multibyte.o file; if you use any
  248.     Internationalization features and need to handle multi-byte
  249.     character sets, do not forget this step.
  250.  
  251.     # /bin/ls -1 | egrep -v .o$
  252.     rpc_commondata.
  253.     rpc_dtablesize.
  254.     xccs.multibyte.
  255.     # mv rpc_commondata. rpc_commondata.o
  256.     # mv rpc_dtablesize. rpc_dtablesize.o
  257.     # mv xccs.multibyte. xccs.multibyte.o
  258.  
  259.  
  260. 8.  Remove the old routine to do the hostname/addr resolution:
  261.  
  262.     # rm gethostent.o
  263.  
  264.  
  265. 9.  Remove the libresolv module that contains `strncasecmp' (which is
  266.     now in the main C library, so it is redundant):
  267.  
  268.     # rm strcasecmp.o
  269.  
  270.  
  271. 10. Go back up to the /usr/lib/shlib.etc directory.
  272.  
  273.     # cd ..
  274.  
  275.  
  276. 11. Edit the lorder-sparc file.  You need to remove the reference to
  277.     gethostent.o and add the references to the new resolver library
  278.     routines.  Use this patch to guide you:
  279.  
  280.     *** lorder-sparc.orig   Fri Jul 17 14:16:19 1992
  281.     --- lorder-sparc        Fri Jul 17 14:17:39 1992
  282.     ***************
  283.     *** 150,154 ****
  284.       getwd.o
  285.       getnetgrent.o
  286.     ! gethostent.o
  287.       ypxdr.o
  288.       ttyname.o
  289.     --- 150,161 ----
  290.       getwd.o
  291.       getnetgrent.o
  292.     ! gethostnamadr.o
  293.     ! sethostent.o
  294.     ! res_query.o
  295.     ! res_mkquery.o
  296.     ! res_send.o
  297.     ! res_debug.o
  298.     ! res_comp.o
  299.     ! res_init.o
  300.       ypxdr.o
  301.       ttyname.o
  302.  
  303.  
  304. 12. If you are running under SunOS 4.1.2, you will want to add the
  305.     entry "mblib.o" to the very end of lorder-sparc.  (If you aren't
  306.     running SunOS 4.1.2, don't worry about this step.)
  307.  
  308.     Besides adding mblib.o to the very end of lorder-sparc, you will
  309.     need to patch the Makefile by adding a "-ldl" to the end of the ld
  310.     commands, as follows:
  311.  
  312.     *** Makefile.orig       Fri Jul 17 14:32:45 1992
  313.     --- Makefile    Fri Jul 17 14:33:41 1992
  314.     ***************
  315.     *** 9,13 ****
  316.       
  317.       libc.so:
  318.     !       ld -assert pure-text `${OBJSORT} lorder-sparc tmp`
  319.             /bin/ls /usr/lib/libc.so.* > TMP_FILE
  320.             mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
  321.     --- 9,13 ----
  322.       
  323.       libc.so:
  324.     !       ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
  325.             /bin/ls /usr/lib/libc.so.* > TMP_FILE
  326.             mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
  327.     ***************
  328.     *** 15,19 ****
  329.       
  330.       libcs5.so:
  331.     !       ld -assert pure-text `${OBJSORT} lorder-sparc tmp`
  332.             /bin/ls /usr/5lib/libc.so.* > TMP_FILE
  333.             mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
  334.     --- 15,19 ----
  335.       
  336.       libcs5.so:
  337.     !       ld -assert pure-text `${OBJSORT} lorder-sparc tmp` -ldl
  338.             /bin/ls /usr/5lib/libc.so.* > TMP_FILE
  339.             mv a.out libc.so.`cat TMP_FILE | awk -f ${AWKFILE}`
  340.  
  341.  
  342. 13. If you don't have the cwd in root's path (as you shouldn't), then
  343.     change the "OBJSORT=objsort" line in the Makefile to
  344.     "OBJSORT=./objsort".
  345.  
  346.  
  347. 14. Make the new libc.so.
  348.  
  349.     # make libc.so
  350.  
  351.     Now you should have some libc.so.x.y.z built in the current
  352.     directory.
  353.  
  354.  
  355. 15. Make sure your /etc/resolv.conf file contains the correct entries
  356.     for your domain.  Also, as resolv+'s README file entails, add the
  357.     "order" line, and set it to your liking.  Ours is:
  358.  
  359.     order local,bind
  360.  
  361.     This means that in attempt to resolve a hostname, first /etc/hosts
  362.     will be checked, and then, if that fails, DNS will be used.  If
  363.     that fails, then an "unknown host" will be returned.
  364.  
  365.     Note that the default if no "order" line is found is to use DNS
  366.     only; the exact same thing that the routines in
  367.     /usr/lib/libresolv.a employ.
  368.  
  369.  
  370. 16. Test out your new libc.so at this point before installing it. You
  371.     can do so by setting the environment variable LD_LIBRARY_PATH to
  372.     the /usr/lib/shlib.etc directory.  Make sure that the hostname
  373.     resolves work, and are being handled as you specified with the
  374.     "order" line in /etc/resolv.conf.
  375.  
  376.  
  377. 17. If you're satisfied that the new library works, you can install
  378.     it, and the new libresolv.a, with the following commands:
  379.  
  380.     # mv /usr/lib/libresolv.a /usr/lib/libresolv.a.OLD
  381.     # cp resolv+/libresolv.a /usr/lib/
  382.     # ranlib /usr/lib/libresolv.a
  383.     # cp libc.so.x.y.z /usr/lib/
  384.     # ldconfig
  385.  
  386.  
  387. 18. You are now running with the new library.  You can verify this by
  388.     doing a trace command of, let's say, "date".
  389.  
  390.     # trace date
  391.  
  392.     The output should informed you that the new library is being used.
  393.  
  394.  
  395. 19. For completeness, you should rebuild libc.a so that people
  396.     compiling with static linking get the name server routines as
  397.     well.  This entails removing the gethostent.o routine, and adding
  398.     the object files from resolv+.
  399.  
  400.     # cd resolv+
  401.     # cp -p /usr/lib/libc.a /usr/lib/libc.a.OLD
  402.     # ar dv /usr/lib/libc.a gethostent.o
  403.     d - gethostent.o
  404.     # ar uv /usr/lib/libc.a *.o
  405.     r - mktemp.o
  406.     r - strpbrk.o
  407.     a - gethostnamadr.o
  408.     a - herror.o
  409.     a - res_comp.o
  410.     a - res_debug.o
  411.     a - res_init.o
  412.     a - res_mkquery.o
  413.     a - res_query.o
  414.     a - res_send.o
  415.     a - sethostent.o
  416.     a - strcasecmp.o
  417.     a - strerror.o
  418.     # ranlib /usr/lib/libc.a
  419.  
  420.  
  421. 20.  Clean up.
  422.  
  423.     # cd ..
  424.     # rm -rf TMP_FILE libc.so.* resolv+ tmp
  425.  
  426. 8<----------/usr/lib/shlib.etc/README.DNS----------cut-here---------->8
  427. -----------------------------------------------------------------------
  428.  
  429.  
  430. Caveats:
  431.  
  432.     Note that existing programs that have been compiled with
  433. static libraries (and not dynamic) will still be as drain-bamaged as
  434. ever.  (The `mount` command, for example.)
  435.  
  436.     If you have the source, then you can recompile these programs.
  437. (Prime example: As the PROBLEMS file with GNU Emacs states, you can
  438. now relink emacs and have hostname resolving work properly.)  If,
  439. however, you don't have the source for the statically linked program,
  440. then you can add an entry to /etc/hosts as a workaround.
  441.  
  442.     I'm still not sure why I couldn't get resolv+ to compile as-is
  443. here; the README file for it specifically says the *only* thing that
  444. should need to be changed is adding -pic to the CFLAGS.
  445.  
  446.  
  447. Parting Comments:
  448.  
  449.     Generous thanks to these people for giving me the leads, tips,
  450. and hints necessary to figure out how to do this:
  451.  
  452. Bill Unruh <unruh@unixg.ubc.ca>
  453. Karsten Leipold <leipold@dfn.de>
  454. Douglas E James <JAMES_DOUGLAS_E@LILLY.COM>
  455. Don Pace <pace@mailer.cc.fsu.edu>
  456. Greg Earle <earle@poseur.JPL.NASA.GOV>
  457. Christopher Davis <ckd@eff.org>
  458. jp107@cus.cam.ac.uk (Jon Peatfield)
  459.  
  460.     Don't take these instructions as gospel.  The only thing I
  461. really know about this process is what I've gleaned while doing it on
  462. our sparc here.  Doubtlessly there are steps here that can be done
  463. better.  Hopefully, if there is a serious problem with one or more of
  464. the steps of this process, then someone will call it to my
  465. <qralston+@pitt.edu> attention.
  466.  
  467.     If you find any inconsistencies, misspellings, errors, etc in
  468. this document, please gripe at me.  If there are steps that could be
  469. made clearer, please tell me so.
  470.  
  471.     Also, most importantly, if there's a BETTER way of doing this,
  472. then please let me in on it.  ;)
  473.  
  474.     If you find these instructions useful, I'd appreciate it if
  475. you'd drop me a line and tell me so, so I'll know that I didn't spend
  476. hours throwing this thing together for nothing.
  477.  
  478.     Regards,
  479.  
  480. James
  481. Fri Jul 17 16:14:26 EDT 1992
  482.  
  483. -- 
  484. James Ralston Crawford \ Advanced Graphics Lab
  485. qralston+@pitt.edu \ qralston@pittvms.bitnet
  486. "I just hate it when people don't think that I'm, well, sane."  -Od
  487. "If someone thought I was sane, I'd worry about THEM."  -Sh
  488.  
  489. --
  490. Craig Richmond.  Computer Officer -  Dept of Economics (morning) 380 3860
  491.   University of Western Australia    Dept of Education (afternoon)
  492. craig@ecel.uwa.edu.au                              Dvorak Keyboards RULE!
  493.      "Only users are allowed to make messes on their computers"  I.M.VI
  494.