6 years, 10 months ago.

set dns server

Hi all, I am trying to set a dns server, can any one help me out in it. I have tried the following piece of code, but no luck

  ip4_addr_set_u32(&primaryDnsServer, ipaddr_addr("a.b.c.d")); 
    dns_setserver(0, &primaryDnsServer);
        ip_addr = dns_getserver(0);
        printf("dns server: %s\n", inet_ntoa(*((struct in_addr*)&(ip_addr))));

done :)

   ip_addr_t primaryDnsServer;
    ip4_addr_set_u32(&primaryDnsServer, ipaddr_addr("your dns address"));
    dns_setserver(1, &primaryDnsServer);
        ip_addr = dns_getserver(1);
        printf("dns server: %s\n", inet_ntoa(*((struct in_addr*)&(ip_addr))));

and dont forget to connect to network before setting the dns configurations

posted by zain aftab 22 Sep 2014
Be the first to answer this question.