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