[Dnsmasq-discuss] Problem with forwarded TCP queries

Simon Capper scapper at ooma.com
Tue Nov 13 20:00:13 GMT 2007


I have dnsmasq (2.35) set up to forward queries for a private domain to a
private dns server, all other queries go to the servers in /etc/resolv. The
server also uses a different source port than the default.

The dnsmaq config for this server looks like:

server=/sub.my_domain/my_domain/10.15.15.12 at 1.0.0.1

When I query "server1.my_domain" using UDP the source address of the
query is 1.0.0.1 as expected.
When I do the same query using TCP the source address is not being set and
the query fails because the socket is trying to connect from the wrong
interface.

I applied this patch to bind the TCP query to the source address in the
config file. 

Should a TCP query honor the source address and is this the best way to fix
this problem?


==== /src_orig/forward.c#1 - /src/forward.c ====
@@ -749,6 +749,7 @@
           
           if ((last_server->tcpfd == -1) &&
               (last_server->tcpfd = socket(last_server->addr.sa.sa_family,
SOCK_STREAM, 0)) != -1 &&
+              bind(last_server->tcpfd, &last_server->source_addr.sa,
sa_len(&last_server->source_addr)) != -1 &&
               connect(last_server->tcpfd, &last_server->addr.sa,
sa_len(&last_server->addr)) == -1)
             {
               close(last_server->tcpfd);
 

Thanks,

Simon





More information about the Dnsmasq-discuss mailing list