1 @(#) README.NIS 1.2 96/02/11 17:24:52
3 > Problem: I have several [machines] with multiple IP addresses, and
4 > when they try to connect to a daemon with tcp wrapper, they are often
5 > rejected. I assume this is due to the -DPARANOID option, and depends
6 > on which IP address is returned first from the nameserver for a given
7 > name. This behavior seems to be random, may depend on ordering in
10 [Note: the situation described below no longer exists. Presently, my
11 internet gateway uses the same IP address on all interfaces. To avoid
12 confusion I have removed the old name wzv-gw.win.tue.nl from the DNS. I
13 have kept the discussion below for educational reasons].
15 NIS was not designed to handle multi-homed hosts. With NIS, each
16 address should have its own hostname. For example, wzv-gw is my
17 gateway. It has two interfaces: one connected to the local ethernet,
18 the other to a serial link. In the NIS it is registered as:
20 131.155.210.23 wzv-gw-ether
21 131.155.12.78 wzv-gw-slip
23 In principle, wzv-gw could be the official name of one of these
24 interfaces, or it could be an alias for both.
26 The DNS was designed to handle multi-homed hosts. In the DNS my gateway
27 is registered in zone win.tue.nl, with one name that has two A records:
29 wzv-gw IN A 131.155.210.23
32 And of course there are PTR records in zones 210.155.131.in-addr.arpa
33 and 12.155.131.in-addr.arpa that point to wzv-gw.win.tue.nl.
35 This setup does not cause any problems. You can test your name service
36 with the two programs below. This is what they say on a local NIS client
37 (both client and server running SunOS 4.1.3_U1):
39 % gethostbyname wzv-gw
40 Hostname: wzv-gw.win.tue.nl
42 Addresses: 131.155.210.23 131.155.12.78
44 % gethostbyaddr 131.155.210.23
45 Hostname: wzv-gw-ether
47 Addresses: 131.155.210.23
49 % gethostbyaddr 131.155.12.78
52 Addresses: 131.155.12.78
54 Things seem less confusing when seen by a NIS client in a different
55 domain (both client and server running SunOS 4.1.3_U1):
57 % gethostbyname wzv-gw.win.tue.nl
58 Hostname: wzv-gw.win.tue.nl
60 Addresses: 131.155.210.23 131.155.12.78
62 % gethostbyaddr 131.155.210.23
63 Hostname: wzv-gw.win.tue.nl
65 Addresses: 131.155.12.78 131.155.210.23
67 % gethostbyaddr 131.155.12.78
68 Hostname: wzv-gw.win.tue.nl
70 Addresses: 131.155.210.23 131.155.12.78
72 Alas, Solaris 2.4 still has problems. This is what I get on a Solaris
73 2.4 NIS client, with a SunOS 4.1.3_U1 NIS server:
75 % gethostbyname wzv-gw.win.tue.nl
76 Hostname: wzv-gw.win.tue.nl
77 Aliases: 131.155.210.23 wzv-gw.win.tue.nl
78 Addresses: 131.155.12.78
80 The tcpd source comes with a workaround for this problem. The
81 workaround is ugly and is not part of the programs attached below.
85 # This is a shell archive. Remove anything before this line, then unpack
86 # it by saving it into a file and typing "sh file". To overwrite existing
87 # files, type "sh file -c". You can also feed this as standard input via
88 # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
89 # will see the following message at the end:
90 # "End of shell archive."
91 # Contents: gethostbyaddr.c gethostbyname.c
92 # Wrapped by wietse@wzv on Sun Jan 8 17:08:48 1995
93 PATH=/bin:/usr/bin:/usr/ucb ; export PATH
94 if test -f gethostbyaddr.c -a "${1}" != "-c" ; then
95 echo shar: Will not over-write existing file \"gethostbyaddr.c\"
97 echo shar: Extracting \"gethostbyaddr.c\" \(1073 characters\)
98 sed "s/^X//" >gethostbyaddr.c <<'END_OF_gethostbyaddr.c'
100 X * gethostbyaddr tester. compile with:
102 X * cc -o gethostbyaddr gethostbyaddr.c (SunOS 4.x)
104 X * cc -o gethostbyaddr gethostbyaddr.c -lnsl (SunOS 5.x)
106 X * run as: gethostbyaddr address
108 X * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
111 X#include <sys/types.h>
112 X#include <sys/socket.h>
113 X#include <netinet/in.h>
114 X#include <arpa/inet.h>
122 X struct hostent *hp;
126 X fprintf(stderr, "usage: %s i.p.addres\n", argv[0]);
129 X addr = inet_addr(argv[1]);
130 X if (hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)) {
131 X printf("Hostname:\t%s\n", hp->h_name);
132 X printf("Aliases:\t");
133 X while (hp->h_aliases[0])
134 X printf("%s ", *hp->h_aliases++);
136 X printf("Addresses:\t");
137 X while (hp->h_addr_list[0])
138 X printf("%s ", inet_ntoa(*(struct in_addr *) * hp->h_addr_list++));
142 X fprintf(stderr, "host %s not found\n", argv[1]);
145 END_OF_gethostbyaddr.c
146 if test 1073 -ne `wc -c <gethostbyaddr.c`; then
147 echo shar: \"gethostbyaddr.c\" unpacked with wrong size!
149 # end of overwriting check
151 if test -f gethostbyname.c -a "${1}" != "-c" ; then
152 echo shar: Will not over-write existing file \"gethostbyname.c\"
154 echo shar: Extracting \"gethostbyname.c\" \(999 characters\)
155 sed "s/^X//" >gethostbyname.c <<'END_OF_gethostbyname.c'
157 X * gethostbyname tester. compile with:
159 X * cc -o gethostbyname gethostbyname.c (SunOS 4.x)
161 X * cc -o gethostbyname gethostbyname.c -lnsl (SunOS 5.x)
163 X * run as: gethostbyname hostname
165 X * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
167 X#include <sys/types.h>
168 X#include <sys/socket.h>
169 X#include <netinet/in.h>
170 X#include <arpa/inet.h>
178 X struct hostent *hp;
181 X fprintf(stderr, "usage: %s hostname\n", argv[0]);
184 X if (hp = gethostbyname(argv[1])) {
185 X printf("Hostname:\t%s\n", hp->h_name);
186 X printf("Aliases:\t");
187 X while (hp->h_aliases[0])
188 X printf("%s ", *hp->h_aliases++);
190 X printf("Addresses:\t");
191 X while (hp->h_addr_list[0])
192 X printf("%s ", inet_ntoa(*(struct in_addr *) * hp->h_addr_list++));
196 X fprintf(stderr, "host %s not found\n", argv[1]);
200 END_OF_gethostbyname.c
201 if test 999 -ne `wc -c <gethostbyname.c`; then
202 echo shar: \"gethostbyname.c\" unpacked with wrong size!
204 # end of overwriting check
206 echo shar: End of shell archive.