# How to disable IPv6?

**URL:** <https://forums.digi.com/t/how-to-disable-ipv6/4310>\
**Category:** NET+OS\
**Tags:** ipv6\
**Created:** [April 22, 2011, 4:16pm UTC](https://forums.digi.com/t/how-to-disable-ipv6/4310 "2011-04-22T16:16:44Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tduncan](https://avatars.discourse-cdn.com/v4/letter/t/e9c0ed/32.png) [@tduncan](https://forums.digi.com/u/tduncan)\
**Post date:** [April 22, 2011, 4:16pm UTC](https://forums.digi.com/t/how-to-disable-ipv6/4310/1 "2011-04-22T16:16:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![rdeabill](https://avatars.discourse-cdn.com/v4/letter/r/91b2a8/32.png) [@rdeabill](https://forums.digi.com/u/rdeabill)\
**Post date:** [April 26, 2011, 8:10am UTC](https://forums.digi.com/t/how-to-disable-ipv6/4310/2 "2011-04-26T08:10:38Z")

</div>

Hi,  
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 *)&amp;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);  
}

---

<div class="post-metadata">

**Author:** ![tduncan](https://avatars.discourse-cdn.com/v4/letter/t/e9c0ed/32.png) [@tduncan](https://forums.digi.com/u/tduncan)\
**Post date:** [April 26, 2011, 1:29pm UTC](https://forums.digi.com/t/how-to-disable-ipv6/4310/3 "2011-04-26T13:29:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dakotas\_dad](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@dakotas\_dad](https://forums.digi.com/u/dakotas_dad)\
**Post date:** [May 3, 2011, 3:28pm UTC](https://forums.digi.com/t/how-to-disable-ipv6/4310/4 "2011-05-03T15:28:12Z")

</div>

Hello

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

```
