1 | @(#) README.NIS 1.2 96/02/11 17:24:52 |
---|
2 | |
---|
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 |
---|
8 | > the YP host map? |
---|
9 | |
---|
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]. |
---|
14 | |
---|
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: |
---|
19 | |
---|
20 | 131.155.210.23 wzv-gw-ether |
---|
21 | 131.155.12.78 wzv-gw-slip |
---|
22 | |
---|
23 | In principle, wzv-gw could be the official name of one of these |
---|
24 | interfaces, or it could be an alias for both. |
---|
25 | |
---|
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: |
---|
28 | |
---|
29 | wzv-gw IN A 131.155.210.23 |
---|
30 | IN A 131.155.12.78 |
---|
31 | |
---|
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. |
---|
34 | |
---|
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): |
---|
38 | |
---|
39 | % gethostbyname wzv-gw |
---|
40 | Hostname: wzv-gw.win.tue.nl |
---|
41 | Aliases: |
---|
42 | Addresses: 131.155.210.23 131.155.12.78 |
---|
43 | |
---|
44 | % gethostbyaddr 131.155.210.23 |
---|
45 | Hostname: wzv-gw-ether |
---|
46 | Aliases: |
---|
47 | Addresses: 131.155.210.23 |
---|
48 | |
---|
49 | % gethostbyaddr 131.155.12.78 |
---|
50 | Hostname: wzv-gw-slip |
---|
51 | Aliases: |
---|
52 | Addresses: 131.155.12.78 |
---|
53 | |
---|
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): |
---|
56 | |
---|
57 | % gethostbyname wzv-gw.win.tue.nl |
---|
58 | Hostname: wzv-gw.win.tue.nl |
---|
59 | Aliases: |
---|
60 | Addresses: 131.155.210.23 131.155.12.78 |
---|
61 | |
---|
62 | % gethostbyaddr 131.155.210.23 |
---|
63 | Hostname: wzv-gw.win.tue.nl |
---|
64 | Aliases: |
---|
65 | Addresses: 131.155.12.78 131.155.210.23 |
---|
66 | |
---|
67 | % gethostbyaddr 131.155.12.78 |
---|
68 | Hostname: wzv-gw.win.tue.nl |
---|
69 | Aliases: |
---|
70 | Addresses: 131.155.210.23 131.155.12.78 |
---|
71 | |
---|
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: |
---|
74 | |
---|
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 |
---|
79 | |
---|
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. |
---|
82 | |
---|
83 | |
---|
84 | #! /bin/sh |
---|
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\" |
---|
96 | else |
---|
97 | echo shar: Extracting \"gethostbyaddr.c\" \(1073 characters\) |
---|
98 | sed "s/^X//" >gethostbyaddr.c <<'END_OF_gethostbyaddr.c' |
---|
99 | X /* |
---|
100 | X * gethostbyaddr tester. compile with: |
---|
101 | X * |
---|
102 | X * cc -o gethostbyaddr gethostbyaddr.c (SunOS 4.x) |
---|
103 | X * |
---|
104 | X * cc -o gethostbyaddr gethostbyaddr.c -lnsl (SunOS 5.x) |
---|
105 | X * |
---|
106 | X * run as: gethostbyaddr address |
---|
107 | X * |
---|
108 | X * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. |
---|
109 | X */ |
---|
110 | X |
---|
111 | X#include <sys/types.h> |
---|
112 | X#include <sys/socket.h> |
---|
113 | X#include <netinet/in.h> |
---|
114 | X#include <arpa/inet.h> |
---|
115 | X#include <netdb.h> |
---|
116 | X#include <stdio.h> |
---|
117 | X |
---|
118 | Xmain(argc, argv) |
---|
119 | Xint argc; |
---|
120 | Xchar **argv; |
---|
121 | X{ |
---|
122 | X struct hostent *hp; |
---|
123 | X long addr; |
---|
124 | X |
---|
125 | X if (argc != 2) { |
---|
126 | X fprintf(stderr, "usage: %s i.p.addres\n", argv[0]); |
---|
127 | X exit(1); |
---|
128 | X } |
---|
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++); |
---|
135 | X printf("\n"); |
---|
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++)); |
---|
139 | X printf("\n"); |
---|
140 | X exit(0); |
---|
141 | X } |
---|
142 | X fprintf(stderr, "host %s not found\n", argv[1]); |
---|
143 | X exit(1); |
---|
144 | X} |
---|
145 | END_OF_gethostbyaddr.c |
---|
146 | if test 1073 -ne `wc -c <gethostbyaddr.c`; then |
---|
147 | echo shar: \"gethostbyaddr.c\" unpacked with wrong size! |
---|
148 | fi |
---|
149 | # end of overwriting check |
---|
150 | fi |
---|
151 | if test -f gethostbyname.c -a "${1}" != "-c" ; then |
---|
152 | echo shar: Will not over-write existing file \"gethostbyname.c\" |
---|
153 | else |
---|
154 | echo shar: Extracting \"gethostbyname.c\" \(999 characters\) |
---|
155 | sed "s/^X//" >gethostbyname.c <<'END_OF_gethostbyname.c' |
---|
156 | X /* |
---|
157 | X * gethostbyname tester. compile with: |
---|
158 | X * |
---|
159 | X * cc -o gethostbyname gethostbyname.c (SunOS 4.x) |
---|
160 | X * |
---|
161 | X * cc -o gethostbyname gethostbyname.c -lnsl (SunOS 5.x) |
---|
162 | X * |
---|
163 | X * run as: gethostbyname hostname |
---|
164 | X * |
---|
165 | X * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. |
---|
166 | X */ |
---|
167 | X#include <sys/types.h> |
---|
168 | X#include <sys/socket.h> |
---|
169 | X#include <netinet/in.h> |
---|
170 | X#include <arpa/inet.h> |
---|
171 | X#include <netdb.h> |
---|
172 | X#include <stdio.h> |
---|
173 | X |
---|
174 | Xmain(argc, argv) |
---|
175 | Xint argc; |
---|
176 | Xchar **argv; |
---|
177 | X{ |
---|
178 | X struct hostent *hp; |
---|
179 | X |
---|
180 | X if (argc != 2) { |
---|
181 | X fprintf(stderr, "usage: %s hostname\n", argv[0]); |
---|
182 | X exit(1); |
---|
183 | X } |
---|
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++); |
---|
189 | X printf("\n"); |
---|
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++)); |
---|
193 | X printf("\n"); |
---|
194 | X exit(0); |
---|
195 | X } else { |
---|
196 | X fprintf(stderr, "host %s not found\n", argv[1]); |
---|
197 | X exit(1); |
---|
198 | X } |
---|
199 | X} |
---|
200 | END_OF_gethostbyname.c |
---|
201 | if test 999 -ne `wc -c <gethostbyname.c`; then |
---|
202 | echo shar: \"gethostbyname.c\" unpacked with wrong size! |
---|
203 | fi |
---|
204 | # end of overwriting check |
---|
205 | fi |
---|
206 | echo shar: End of shell archive. |
---|
207 | exit 0 |
---|