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@xxxxxxxxxxxxxxx http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc