How to disable IPv6?

I’m converting a Net+OS 6.3 project to 7.5. When it starts up, I see it broadcast a few ICMPv6 messages in Wireshark, then it does a DHCP Discover. The DHCP server provides an IPv4 address, mask, gateway, DNS server, etc. as expected. Then, it gets to “applicationStart” where I have placed a line -

numServers = DNSGetServers(servers_list, 4);

There’s ONE server in the list and its family is AF_INET(6). There’s no IPv4 server address in the list. And subsequent calls to getaddrinfo don’t work.

I don’t care about IPv6 right now. I want my app to work with IPv4 as it always has. I’ll upgrade it to support v6 later. So i thought I’d just disable v6 support in my app. I found APP_USE_STATIC_IPV6 and APP_USE_DHCPV6 in appconf.h. Both are set to APP_ON_NO_INTERFACE, but APP_USE_NVRAM is set to APP_FOR_ALL_PARAMETERS which is what I want (for all other parameters). But because of that, these two parameters use the NVRAM setting which I suspect enables them.

So I have two questions for anyone who can help -

  1. Shouldn’t DHCP have added an IPv4 DNS server to the list?
  2. How can I disable IPv6 regardless of the NVRAM settings?
  • Tim

In answer to the first part opf your question DNSGetServers will only return IP addresses in IPV6 format, even if they are IPV4. You should be able to able to remove and add DNS servers with DNSRemoveServer and DNSAddServer.

I use the following routine to addd IPV4 DNS Servers:

static int AddServerAsString(char * src)
struct sockaddr_storage ipaddr;
int status;

memset((void *)&ipaddr, 0, sizeof(ipaddr));

ipaddr.ss_family = AF_INET;
ipaddr.ss_len = sizeof(ipaddr);
if (!inet_pton(AF_INET, src, &(ipaddr.addr.ipv4.sin_addr))) {
printf("ERROR: Invalid DNS Server Address
return (-1);
else {
status = DNSAddServer(&ipaddr);
if (status) {
printf ("Unable to add a DNS server with IP[%s]. Status: %d
", src, status);
return (-1);
return (0);

Thanks for the tidbit about DNS being only IPv6. I re-read the API Reference on that, and indeed, IPv4 sddresses “… are stored as IPv4-mapped IPv6 addresses …”, but only when running in “dual stack mode.” So this brings me round to my second question - how to disable IPv6? I tried setting APP_USE_NVRAM to APP_DO_NOT_USE_NVRAM (refer to my original post), but that didn’t help. What am I missing here? Has anyone ever successfully disabled IPv4?

I follow your AddServerAsString function, but it requires you to know the server address in advance. In my case, if my app is configured to use DHCP, I don’t necessarily know the servers’ addresses, so I want to get them through DHCP. And, following the DHCP transaction in Wireshark, I see the DHCP server sending the DNS addresses (in IPv4) to my app. Is Net+OS 7 “mapping” them to IPv6? What’s going on there?

  • Tim


 NET+OS does not supply a method (API) for disabling ipV6 nor can ipV6 be disabled via any other means.