144743Smarkm@(#) README.NIS 1.2 96/02/11 17:24:52 244743Smarkm 344743Smarkm> Problem: I have several [machines] with multiple IP addresses, and 444743Smarkm> when they try to connect to a daemon with tcp wrapper, they are often 544743Smarkm> rejected. I assume this is due to the -DPARANOID option, and depends 644743Smarkm> on which IP address is returned first from the nameserver for a given 744743Smarkm> name. This behavior seems to be random, may depend on ordering in 844743Smarkm> the YP host map? 944743Smarkm 1044743Smarkm[Note: the situation described below no longer exists. Presently, my 1144743Smarkminternet gateway uses the same IP address on all interfaces. To avoid 1244743Smarkmconfusion I have removed the old name wzv-gw.win.tue.nl from the DNS. I 1344743Smarkmhave kept the discussion below for educational reasons]. 1444743Smarkm 1544743SmarkmNIS was not designed to handle multi-homed hosts. With NIS, each 1644743Smarkmaddress should have its own hostname. For example, wzv-gw is my 1744743Smarkmgateway. It has two interfaces: one connected to the local ethernet, 1844743Smarkmthe other to a serial link. In the NIS it is registered as: 1944743Smarkm 2044743Smarkm 131.155.210.23 wzv-gw-ether 2144743Smarkm 131.155.12.78 wzv-gw-slip 2244743Smarkm 2344743SmarkmIn principle, wzv-gw could be the official name of one of these 2444743Smarkminterfaces, or it could be an alias for both. 2544743Smarkm 2644743SmarkmThe DNS was designed to handle multi-homed hosts. In the DNS my gateway 2744743Smarkmis registered in zone win.tue.nl, with one name that has two A records: 2844743Smarkm 2944743Smarkm wzv-gw IN A 131.155.210.23 3044743Smarkm IN A 131.155.12.78 3144743Smarkm 3244743SmarkmAnd of course there are PTR records in zones 210.155.131.in-addr.arpa 3344743Smarkmand 12.155.131.in-addr.arpa that point to wzv-gw.win.tue.nl. 3444743Smarkm 3544743SmarkmThis setup does not cause any problems. You can test your name service 3644743Smarkmwith the two programs below. This is what they say on a local NIS client 3744743Smarkm(both client and server running SunOS 4.1.3_U1): 3844743Smarkm 3944743Smarkm % gethostbyname wzv-gw 4044743Smarkm Hostname: wzv-gw.win.tue.nl 4144743Smarkm Aliases: 4244743Smarkm Addresses: 131.155.210.23 131.155.12.78 4344743Smarkm 4444743Smarkm % gethostbyaddr 131.155.210.23 4544743Smarkm Hostname: wzv-gw-ether 4644743Smarkm Aliases: 4744743Smarkm Addresses: 131.155.210.23 4844743Smarkm 4944743Smarkm % gethostbyaddr 131.155.12.78 5044743Smarkm Hostname: wzv-gw-slip 5144743Smarkm Aliases: 5244743Smarkm Addresses: 131.155.12.78 5344743Smarkm 5444743SmarkmThings seem less confusing when seen by a NIS client in a different 5544743Smarkmdomain (both client and server running SunOS 4.1.3_U1): 5644743Smarkm 5744743Smarkm % gethostbyname wzv-gw.win.tue.nl 5844743Smarkm Hostname: wzv-gw.win.tue.nl 5944743Smarkm Aliases: 6044743Smarkm Addresses: 131.155.210.23 131.155.12.78 6144743Smarkm 6244743Smarkm % gethostbyaddr 131.155.210.23 6344743Smarkm Hostname: wzv-gw.win.tue.nl 6444743Smarkm Aliases: 6544743Smarkm Addresses: 131.155.12.78 131.155.210.23 6644743Smarkm 6744743Smarkm % gethostbyaddr 131.155.12.78 6844743Smarkm Hostname: wzv-gw.win.tue.nl 6944743Smarkm Aliases: 7044743Smarkm Addresses: 131.155.210.23 131.155.12.78 7144743Smarkm 7244743SmarkmAlas, Solaris 2.4 still has problems. This is what I get on a Solaris 7344743Smarkm2.4 NIS client, with a SunOS 4.1.3_U1 NIS server: 7444743Smarkm 7544743Smarkm % gethostbyname wzv-gw.win.tue.nl 7644743Smarkm Hostname: wzv-gw.win.tue.nl 7744743Smarkm Aliases: 131.155.210.23 wzv-gw.win.tue.nl 7844743Smarkm Addresses: 131.155.12.78 7944743Smarkm 8044743SmarkmThe tcpd source comes with a workaround for this problem. The 8144743Smarkmworkaround is ugly and is not part of the programs attached below. 8244743Smarkm 8344743Smarkm 8444743Smarkm#! /bin/sh 8544743Smarkm# This is a shell archive. Remove anything before this line, then unpack 8644743Smarkm# it by saving it into a file and typing "sh file". To overwrite existing 8744743Smarkm# files, type "sh file -c". You can also feed this as standard input via 8844743Smarkm# unshar, or by typing "sh <file", e.g.. If this archive is complete, you 8944743Smarkm# will see the following message at the end: 9044743Smarkm# "End of shell archive." 9144743Smarkm# Contents: gethostbyaddr.c gethostbyname.c 9244743Smarkm# Wrapped by wietse@wzv on Sun Jan 8 17:08:48 1995 9344743SmarkmPATH=/bin:/usr/bin:/usr/ucb ; export PATH 9444743Smarkmif test -f gethostbyaddr.c -a "${1}" != "-c" ; then 9544743Smarkm echo shar: Will not over-write existing file \"gethostbyaddr.c\" 9644743Smarkmelse 9744743Smarkmecho shar: Extracting \"gethostbyaddr.c\" \(1073 characters\) 9844743Smarkmsed "s/^X//" >gethostbyaddr.c <<'END_OF_gethostbyaddr.c' 9944743SmarkmX /* 10044743SmarkmX * gethostbyaddr tester. compile with: 10144743SmarkmX * 10244743SmarkmX * cc -o gethostbyaddr gethostbyaddr.c (SunOS 4.x) 10344743SmarkmX * 10444743SmarkmX * cc -o gethostbyaddr gethostbyaddr.c -lnsl (SunOS 5.x) 10544743SmarkmX * 10644743SmarkmX * run as: gethostbyaddr address 10744743SmarkmX * 10844743SmarkmX * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. 10944743SmarkmX */ 11044743SmarkmX 11144743SmarkmX#include <sys/types.h> 11244743SmarkmX#include <sys/socket.h> 11344743SmarkmX#include <netinet/in.h> 11444743SmarkmX#include <arpa/inet.h> 11544743SmarkmX#include <netdb.h> 11644743SmarkmX#include <stdio.h> 11744743SmarkmX 11844743SmarkmXmain(argc, argv) 11944743SmarkmXint argc; 12044743SmarkmXchar **argv; 12144743SmarkmX{ 12244743SmarkmX struct hostent *hp; 12344743SmarkmX long addr; 12444743SmarkmX 12544743SmarkmX if (argc != 2) { 12644743SmarkmX fprintf(stderr, "usage: %s i.p.addres\n", argv[0]); 12744743SmarkmX exit(1); 12844743SmarkmX } 12944743SmarkmX addr = inet_addr(argv[1]); 13044743SmarkmX if (hp = gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)) { 13144743SmarkmX printf("Hostname:\t%s\n", hp->h_name); 13244743SmarkmX printf("Aliases:\t"); 13344743SmarkmX while (hp->h_aliases[0]) 13444743SmarkmX printf("%s ", *hp->h_aliases++); 13544743SmarkmX printf("\n"); 13644743SmarkmX printf("Addresses:\t"); 13744743SmarkmX while (hp->h_addr_list[0]) 13844743SmarkmX printf("%s ", inet_ntoa(*(struct in_addr *) * hp->h_addr_list++)); 13944743SmarkmX printf("\n"); 14044743SmarkmX exit(0); 14144743SmarkmX } 14244743SmarkmX fprintf(stderr, "host %s not found\n", argv[1]); 14344743SmarkmX exit(1); 14444743SmarkmX} 14544743SmarkmEND_OF_gethostbyaddr.c 14644743Smarkmif test 1073 -ne `wc -c <gethostbyaddr.c`; then 14744743Smarkm echo shar: \"gethostbyaddr.c\" unpacked with wrong size! 14844743Smarkmfi 14944743Smarkm# end of overwriting check 15044743Smarkmfi 15144743Smarkmif test -f gethostbyname.c -a "${1}" != "-c" ; then 15244743Smarkm echo shar: Will not over-write existing file \"gethostbyname.c\" 15344743Smarkmelse 15444743Smarkmecho shar: Extracting \"gethostbyname.c\" \(999 characters\) 15544743Smarkmsed "s/^X//" >gethostbyname.c <<'END_OF_gethostbyname.c' 15644743SmarkmX /* 15744743SmarkmX * gethostbyname tester. compile with: 15844743SmarkmX * 15944743SmarkmX * cc -o gethostbyname gethostbyname.c (SunOS 4.x) 16044743SmarkmX * 16144743SmarkmX * cc -o gethostbyname gethostbyname.c -lnsl (SunOS 5.x) 16244743SmarkmX * 16344743SmarkmX * run as: gethostbyname hostname 16444743SmarkmX * 16544743SmarkmX * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands. 16644743SmarkmX */ 16744743SmarkmX#include <sys/types.h> 16844743SmarkmX#include <sys/socket.h> 16944743SmarkmX#include <netinet/in.h> 17044743SmarkmX#include <arpa/inet.h> 17144743SmarkmX#include <netdb.h> 17244743SmarkmX#include <stdio.h> 17344743SmarkmX 17444743SmarkmXmain(argc, argv) 17544743SmarkmXint argc; 17644743SmarkmXchar **argv; 17744743SmarkmX{ 17844743SmarkmX struct hostent *hp; 17944743SmarkmX 18044743SmarkmX if (argc != 2) { 18144743SmarkmX fprintf(stderr, "usage: %s hostname\n", argv[0]); 18244743SmarkmX exit(1); 18344743SmarkmX } 18444743SmarkmX if (hp = gethostbyname(argv[1])) { 18544743SmarkmX printf("Hostname:\t%s\n", hp->h_name); 18644743SmarkmX printf("Aliases:\t"); 18744743SmarkmX while (hp->h_aliases[0]) 18844743SmarkmX printf("%s ", *hp->h_aliases++); 18944743SmarkmX printf("\n"); 19044743SmarkmX printf("Addresses:\t"); 19144743SmarkmX while (hp->h_addr_list[0]) 19244743SmarkmX printf("%s ", inet_ntoa(*(struct in_addr *) * hp->h_addr_list++)); 19344743SmarkmX printf("\n"); 19444743SmarkmX exit(0); 19544743SmarkmX } else { 19644743SmarkmX fprintf(stderr, "host %s not found\n", argv[1]); 19744743SmarkmX exit(1); 19844743SmarkmX } 19944743SmarkmX} 20044743SmarkmEND_OF_gethostbyname.c 20144743Smarkmif test 999 -ne `wc -c <gethostbyname.c`; then 20244743Smarkm echo shar: \"gethostbyname.c\" unpacked with wrong size! 20344743Smarkmfi 20444743Smarkm# end of overwriting check 20544743Smarkmfi 20644743Smarkmecho shar: End of shell archive. 20744743Smarkmexit 0 208