Home/Support/Support Forum/How to get DNS address?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

How to get DNS address?

0 votes
I'm using Connect ME9210 with NET+OS.

Is there any way to read DNS address when DHCP is enabled? I use 'customizeIamGetIfAddrInfo()' which gives me current IP, subnet mask, gateway, but DNS is reported as
Even if I disable the DHCP and it uses "APP_PRIMARY_DNS_ADDRESS" defined in "appconf.h", the function still returns DNS as zero.

Many thanks for suggestions
asked Jan 27, 2017 in NET+OS by stepik New to the Community (4 points)

Please log in or register to answer this question.

1 Answer

0 votes
are you running Netos 7.5.2 with all the patches?
are you able to run: C:\netos75\src\examples\nadnsclnt\ example app? Works fine here
answered Jan 29, 2017 by LeonidM Veteran of the Digi Community (4,457 points)

yes I'm running NETOS 7.5.2. All patches installed.

The example works fine. Thanks for it. The function "DNSGetServers()" works fine for me. I can use it instead of "customizeIamGetIfAddrInfo()".

Also, does the NETOS use DNS translation when it boots up? Meaning, can I configure for example SNTP server by its name instead of address?

#define APP_SNTP_PRIMARY              "1.gb.pool.ntp.org"

instead of

#define APP_SNTP_PRIMARY              ""   

Thanks for answer
i beleive it has to be the IP, but you can easily change this. It is used in C:\netos75\src\bsp\common\C:\netos75\src\bsp\common\appconf_api.c

 * Returns the value of @link APP_SNTP_PRIMARY  as defined in appconf.h
 * @external
 * @include     "appconf_api.h"
 * @category SystemSWServices:ApplicationConfiguration
 * @since 6.0
 * @return IP-Address       IP Address of primary SNTP server.
 * @return NULL                APP_SNTP_PRIMARY is not defined.
char * NAGetAppSntpPrimary(void)
        return (APP_SNTP_PRIMARY);
        return (NULL);

chust change this function so it will accept hostname and resolve it.

Thanks for suggestion.
I've tried to modify the function, but the problem is if you want to translate the host name using "getaddrinfo()" inside the function "NAGetAppSntpPrimary()" it does not work. It just get stuck. I guess the problem is that network connection is not established yet while calling the function "NAGetAppSntpPrimary()" and so it cannot access the DNS.

So it seems the only option is to use just an IP address.

Thank you