# Enable IPv6 in container

**URL:** <https://forums.balena.io/t/enable-ipv6-in-container/366731>\
**Category:** balenaOS\
**Tags:** docker, network\
**Created:** [February 13, 2023, 7:51pm UTC](https://forums.balena.io/t/enable-ipv6-in-container/366731 "2023-02-13T19:51:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![caodev](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@caodev](https://forums.balena.io/u/caodev)\
**Post date:** [February 13, 2023, 7:51pm UTC](https://forums.balena.io/t/enable-ipv6-in-container/366731/1 "2023-02-13T19:51:23Z")

</div>

Hello! I’m trying to create a Balena single container to run a custom application that I’ve written that uses bind() to create an IPv6 only server listening on a localhost port. The application runs fine on my host machine but every time I try to run the application in the container I’m met with the error “Cannot assign requested address”. Here’s an example snippet:

```auto
tcp_fd = socket(AF_INET6, SOCK_STREAM, 0);

memset((void *)&addr, 0, sizeof(addr));
addr.sin6_family = AF_INET6;
addr.sin6_port = htons(port);
addr.sin6_addr = onlylocal ? in6addr_loopback : in6addr_any;
bind(tcp_fd, (struct sockaddr *)&addr, sizeof(addr)) < 0);

```

On further investigation I found that the container does not have IPv6 at all:

```auto
root@f07f785919a8:# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
23: eth0@if24: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:0a:72:65:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet xxx.xxx.xxx.xxx/24 brd xxx.xxx.xxx.xxx scope global eth0
       valid_lft forever preferred_lft forever

```

Is there a way to enable IPv6 inside a Balena single container? Additionally, the goal is to connect multiple of these containers using IPV6 sockets, the applications connect and talk to each other using a socket IPC method.

---

<div class="post-metadata">

**Author:** ![caodev](https://avatars.discourse-cdn.com/v4/letter/c/b487fb/32.png) [@caodev](https://forums.balena.io/u/caodev)\
**Post date:** [February 13, 2023, 11:06pm UTC](https://forums.balena.io/t/enable-ipv6-in-container/366731/2 "2023-02-13T23:06:08Z")

</div>

I solved this by creating a file /etc/docker/daemon.json and enabling IPv6, then restarting balena with `systemctl restart balena` and running a new container.

```auto
{
  "ipv6": true,
  "fixed-cidr-v6": "2001:db8:1::/64"
}

```

> **[Enable IPv6 support](https://docs.docker.com/config/daemon/ipv6/)**
>
> How to enable IPv6 support in the Docker daemon

---

<div class="post-metadata">

**Author:** ![Jazzagi](https://avatars.discourse-cdn.com/v4/letter/j/9de0a6/32.png) [@Jazzagi](https://forums.balena.io/u/Jazzagi)\
**Post date:** [February 23, 2023, 1:47pm UTC](https://forums.balena.io/t/enable-ipv6-in-container/366731/3 "2023-02-23T13:47:53Z")

</div>

Great to hear you solved this! Thanks for confirming and sharing your fix 🙂
