This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF9160 Modem Firmware v1.0.0: Setting custom DNS server

Hello,

The release-notes of the Modem Firmware v1.0.0 for the nRF9160 state that there is now "Support for DNS server address setting by application.". However, I cannot find how to actually use this feature anywhere.

Is there perhaps an AT-command that is not documented yet? I'm looking at the AT Command Reference v1.0.

Can someone please help me out?

Parents Reply Children
  • Hi, thank for you for a quick reply! 


    Is there any info on using that?

    nrfxlib/bsdlib/include/nrf_socket.h states that the first argument is IP family, which is according to 
    https://www.iana.org/assignments/address-family-numbers/address-family-numbers.xhtml
    should be 1 for IP4, but then the funciton gives back error 22 (invalid parameter).

    With 2 it gives back 0 error code, but then AT+CGCONTRDP=0 still shows that DNS is not set, and getaddrinfo results in error 60 (timeout).

    I am trying to use OpenDNS (208.67.222.222 and 208.67.222.220), obviously converted to uint32, as the function requires.

    So, any example (even small code snippet) on how to set OpenDNS addresses would be HIGHLY APPRECIATED. Ideally both (primary and secondary), but this function states that it sets only secondary... But at least something to get DNS working.

    Thank you so much!

    P.S. Source code of this function is not open source, or? Then we could look into implementation/used AT command and not bother you.

    But it looks like controlling the modem happens not just via AT commands.

  • Hello,

    it worked with GoogleDNS! (8.8.8.8).

    Now DNS resolving is working.

    #include <nrf_socket.h>
    
    struct nrf_in_addr dns;
    dns.s_addr = 134744072; // Google DNS, 8.8.8.8
    const int err = nrf_setdnsaddr(2, &dns);
    printk("DNS set result %d\n", err);

    It can be called before the rest of modem configuration, i.e. before w_lte_lc_init in lte_lc.c

    However:

    1) I needed to give 2 as first parameter, not 1.

    2) AT+CGCONTRDP=0 still shows only APN set, no DNS

    3) I would expect it to work with various DNS Servers, including OpenDNS  (208.67.222.222 and 208.67.222.220)

Related