From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Rabbitson Date: Tue, 12 Jun 2007 10:02:18 +0000 Subject: Re: [LARTC] Re: multiple routing tables for internal router programs Message-Id: <466E6F2A.7090202@rabbit.us> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: lartc@vger.kernel.org Salim S I wrote: > Here is my issue with ping. > > When I use -I with ping, the DNS queries for that domain is still sent > out with wrong source address through the interface, and hence, no > reply. This happens in both WAN interfaces. > When I add rules in OUTPUT chain to reroute packets with the unmatching > source address and output interface, things work fine. > > When I use IP address instead of URL, everything is fine. > The problem is ping itself, which uses gethostbyname() which in turn does not understand how to bind to specific interfaces etc. Besides specifying IP addresses instead of hostnames is much much better IMHO. Here is the ping.c snippet: while (argc > 0) { target = *argv; bzero((char *)&whereto, sizeof(whereto)); whereto.sin_family = AF_INET; if (inet_aton(target, &whereto.sin_addr) = 1) { hostname = target; if (argc = 1) options |= F_NUMERIC; } else { hp = gethostbyname2(target, AF_INET); if (!hp) { fprintf(stderr, "ping: unknown host %s\n", target); exit(2); } memcpy(&whereto.sin_addr, hp->h_addr, 4); strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1); hnamebuf[sizeof(hnamebuf) - 1] = 0; hostname = hnamebuf; } if (argc > 1) route[nroute++] = whereto.sin_addr.s_addr; argc--; argv++; } _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc