Project Home
Project Home
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - How to Fix the Source IP used in DNS Request sent from system.: (8 Items)
   
How to Fix the Source IP used in DNS Request sent from system.  
Hi,

We were developing an application which requires DNS Resolution for certain configured URIs.
Now i understand that this can be done by using APIs gethostbyname or getaddrinfo.

However we have an additional problem to handle. The DNS request sent to the DNS server should use a fixed known Source 
IP address in the packets sent towards DNS Server. Is it possible to force/specify DNS Service to use a fixed Source IP?
 
We have multiple logical IP addresses configured on an interface. We just want that DNS resolution should somehow be 
carried out using 1 specific Source IP address in the pkts sent towards DNS Server.

BR
Sajal
Re: How to Fix the Source IP used in DNS Request sent from system.  
Hi Sajal,
The DNS request will be sent to the servers specified in /etc/resolv.conf and the source address used will be the one 
that best routes to that address. As there cannot be multiple addresses in the same subnet, one address will always be 
chosen to access a particular DNS server.

Can you explain in a bit more detail the issue that you are facing?

Regards,
Nick.
Re: How to Fix the Source IP used in DNS Request sent from system.  
Hi Nick,

Thanks for your Reply.
It seems in QNX we can configure multiple logical IP Addresses in Same
Subnet on a particular ethernet interface.
Now since this is not blocked by OS, we want to somehow control which IP
Address the OS uses as Source IP while generating DNS Traffic. Is this
possible somehow?

Further needed help on another related topic:
While we configured the DNS Server IP in resolv.conf:
- We were observing that on calling "gethostbyname()" API, OS was
generating DNS Request and on not getting any reply it was making
re-attempts (6 times or so) before returning failure.
- If 2 DNS Server IPs are configured in resolv.conf then we observe that
the delay between subsequent attempts further increases with period of each
attempt also increasing incremently.
- Also we observed that when resolv.conf is in use, then on executing "arp
-a" or doing FTP, we see that OS Starts generating DNS Traffic for each IP
in ARP Table and there is a delay in output.

Queries:
- In Linux we know it is possible to control the number of attempts and
interval between each attempt by configuring parameters in resolv.conf. Is
the same also possible in QNX?
- How can we stop generation of DNS Traffic on execution of commands like
"arp -a" or ftp?

Would really appreciate if you can provide some pointers for these queries.

Thanks and Regards
Sajal

BR
Sajal

On Mon, Jan 5, 2015 at 8:30 PM, Nick Reilly <community-noreply@qnx.com>
wrote:

> Hi Sajal,
> The DNS request will be sent to the servers specified in /etc/resolv.conf
> and the source address used will be the one that best routes to that
> address. As there cannot be multiple addresses in the same subnet, one
> address will always be chosen to access a particular DNS server.
>
> Can you explain in a bit more detail the issue that you are facing?
>
> Regards,
> Nick.
>
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post112822
> To cancel your subscription to this discussion, please e-mail
> general-networking-unsubscribe@community.qnx.com
>
Attachment: HTML sf-attachment-mime28291 2.91 KB
Re: How to Fix the Source IP used in DNS Request sent from system.  
For arp, pass the -n switch:

# arp -an

I don't see any dns activity with ftp if numeric addresses are used.
If a hostname is used, dns is required to resolve it to a numeric
address.

You can change timeout parameters in resolv.conf:

options timeout:x attempts:y

Or from code:

# include <resolv.h>

struct  __res_state * res = __res_get_state();

res->retrans = x;
res->retry = y;

getaddrinfo(...);

On Wed, Jan 07, 2015 at 01:48:14PM +0530, Sajal Malhotra wrote:
> Hi Nick,
> 
> Thanks for your Reply.
> It seems in QNX we can configure multiple logical IP Addresses in Same Subnet
> on a particular ethernet interface.
> Now since this is not blocked by OS, we want to somehow control which IP
> Address the OS uses as Source IP while generating DNS Traffic. Is this possible
> somehow?
> 
> Further needed help on another related topic: 
> While we configured the DNS Server IP in resolv.conf:
> - We were observing that on calling "gethostbyname()" API, OS was generating
> DNS Request and on not getting any reply it was making re-attempts (6 times or
> so) before returning failure. 
> - If 2 DNS Server IPs are configured in resolv.conf then we observe that the
> delay between subsequent attempts further increases with period of each attempt
> also increasing incremently.
> - Also we observed that when resolv.conf is in use, then on executing "arp -a"
> or doing FTP, we see that OS Starts generating DNS Traffic for each IP in ARP
> Table and there is a delay in output.
> 
> Queries:
> - In Linux we know it is possible to control the number of attempts and
> interval between each attempt by configuring parameters in resolv.conf. Is the
> same also possible in QNX?
> - How can we stop generation of DNS Traffic on execution of commands like "arp
> -a" or ftp?
> 
> Would really appreciate if you can provide some pointers for these queries.
> 
> Thanks and Regards
> Sajal
> 
> BR
> Sajal
> 
> On Mon, Jan 5, 2015 at 8:30 PM, Nick Reilly <community-noreply@qnx.com> wrote:
> 
>     Hi Sajal,
>     The DNS request will be sent to the servers specified in /etc/resolv.conf
>     and the source address used will be the one that best routes to that
>     address. As there cannot be multiple addresses in the same subnet, one
>     address will always be chosen to access a particular DNS server.
> 
>     Can you explain in a bit more detail the issue that you are facing?
> 
>     Regards,
>     Nick.
> 
> 
> 
> 
>     _______________________________________________
> 
>     General
>     http://community.qnx.com/sf/go/post112822
>     To cancel your subscription to this discussion, please e-mail
>     general-networking-unsubscribe@community.qnx.com
> 
> 
Re: How to Fix the Source IP used in DNS Request sent from system.  
On Wed, Jan 07, 2015 at 09:38:36AM -0500, Sean Boudreau wrote:
> 
> For arp, pass the -n switch:
> 
> # arp -an
> 
> I don't see any dns activity with ftp if numeric addresses are used.
> If a hostname is used, dns is required to resolve it to a numeric
> address.
> 
> You can change timeout parameters in resolv.conf:
> 
> options timeout:x attempts:y
> 
> Or from code:
> 
> # include <resolv.h>
> 
> struct  __res_state * res = __res_get_state();
> 
> res->retrans = x;
> res->retry = y;

res_ninit(res);

> 
> getaddrinfo(...);
Re: How to Fix the Source IP used in DNS Request sent from system.  
Hi Sean,

Thanks for your help. Here are my findings after trying your suggestions:
- The arp -an option worked fine. Thankyou for the same :)
- timeout params in resolv.conf did not work(I have attached the
resolv.conf we used).
- However changing "res->retrans" and "res->retry" and res_init() *Did work
fine*. (Please Note: res_ninit does not seem to be supported on our version
of QNX OS (v6.3.0). Was getting compilation errors.)

- Also regarding dns activity in FTP and Telnet, we do see still see the
same. I have attached the wireshark logs of the time when we just executed
a simple ftp command with numeric IP Addresses (ftp 192.168.255.131).  The
Telnet and FTP commands get stuck till these pkt transmissions are
completed. (Please use "dns" filter in pcap file to see the query pkts that
are generated by kernel)

The moment we remove DNS Server IPs from resolv.conf, the issue is not
seen. Can you put some light on this as well.

PS: We are using QNX v6.3.0.

BR
Sajal

On Wed, Jan 7, 2015 at 8:16 PM, Sean Boudreau <community-noreply@qnx.com>
wrote:

> On Wed, Jan 07, 2015 at 09:38:36AM -0500, Sean Boudreau wrote:
> >
> > For arp, pass the -n switch:
> >
> > # arp -an
> >
> > I don't see any dns activity with ftp if numeric addresses are used.
> > If a hostname is used, dns is required to resolve it to a numeric
> > address.
> >
> > You can change timeout parameters in resolv.conf:
> >
> > options timeout:x attempts:y
> >
> > Or from code:
> >
> > # include <resolv.h>
> >
> > struct  __res_state * res = __res_get_state();
> >
> > res->retrans = x;
> > res->retry = y;
>
> res_ninit(res);
>
> >
> > getaddrinfo(...);
>
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post112854
> To cancel your subscription to this discussion, please e-mail
> general-networking-unsubscribe@community.qnx.com
>
Attachment: HTML sf-attachment-mime28514 3.49 KB Text Resolv.conf.txt 72 bytes Text addr_arpa.pcap 30.84 KB
Re: How to Fix the Source IP used in DNS Request sent from system.  
Hi Nick, Sean,

Any Inputs you could give on my queries in last post.

BR
Sajal

On Mon, Jan 19, 2015 at 1:32 PM, Sajal Malhotra <sajalmalhotra@gmail.com>
wrote:

> Hi Sean,
>
> Thanks for your help. Here are my findings after trying your suggestions:
> - The arp -an option worked fine. Thankyou for the same :)
> - timeout params in resolv.conf did not work(I have attached the
> resolv.conf we used).
> - However changing "res->retrans" and "res->retry" and res_init() *Did
> work fine*. (Please Note: res_ninit does not seem to be supported on our
> version of QNX OS (v6.3.0). Was getting compilation errors.)
>
> - Also regarding dns activity in FTP and Telnet, we do see still see the
> same. I have attached the wireshark logs of the time when we just executed
> a simple ftp command with numeric IP Addresses (ftp 192.168.255.131).  The
> Telnet and FTP commands get stuck till these pkt transmissions are
> completed. (Please use "dns" filter in pcap file to see the query pkts that
> are generated by kernel)
>
> The moment we remove DNS Server IPs from resolv.conf, the issue is not
> seen. Can you put some light on this as well.
>
> PS: We are using QNX v6.3.0.
>
> BR
> Sajal
>
> On Wed, Jan 7, 2015 at 8:16 PM, Sean Boudreau <community-noreply@qnx.com>
> wrote:
>
>> On Wed, Jan 07, 2015 at 09:38:36AM -0500, Sean Boudreau wrote:
>> >
>> > For arp, pass the -n switch:
>> >
>> > # arp -an
>> >
>> > I don't see any dns activity with ftp if numeric addresses are used.
>> > If a hostname is used, dns is required to resolve it to a numeric
>> > address.
>> >
>> > You can change timeout parameters in resolv.conf:
>> >
>> > options timeout:x attempts:y
>> >
>> > Or from code:
>> >
>> > # include <resolv.h>
>> >
>> > struct  __res_state * res = __res_get_state();
>> >
>> > res->retrans = x;
>> > res->retry = y;
>>
>> res_ninit(res);
>>
>> >
>> > getaddrinfo(...);
>>
>>
>>
>>
>> _______________________________________________
>>
>> General
>> http://community.qnx.com/sf/go/post112854
>> To cancel your subscription to this discussion, please e-mail
>> general-networking-unsubscribe@community.qnx.com
>>
>
>
Attachment: HTML sf-attachment-mime28711 4.12 KB
Re: How to Fix the Source IP used in DNS Request sent from system.  
6.3.0 is really really old. I'd suggest that if you really need this to work you purchase a support contract and come in
 through that way. Otherwise try 6.5.0 SP1 or 6.6.0.