Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support basic IPv6 #3780

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions supervisor/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
DOCKER_NETWORK = "hassio"
DOCKER_NETWORK_MASK = ip_network("172.30.32.0/23")
DOCKER_NETWORK_RANGE = ip_network("172.30.33.0/24")
DOCKER_NETWORK_LINK_LOCAL = ip_network("fd00:172:30:32::/64")
pvizeli marked this conversation as resolved.
Show resolved Hide resolved

# This needs to match the dockerd --cpu-rt-runtime= argument.
DOCKER_CPU_RUNTIME_TOTAL = 950_000
Expand Down
20 changes: 16 additions & 4 deletions supervisor/docker/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
import docker
import requests

from ..const import DOCKER_NETWORK, DOCKER_NETWORK_MASK, DOCKER_NETWORK_RANGE
from ..const import (
DOCKER_NETWORK,
DOCKER_NETWORK_LINK_LOCAL,
DOCKER_NETWORK_MASK,
DOCKER_NETWORK_RANGE,
)
from ..exceptions import DockerError

_LOGGER: logging.Logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -80,19 +85,26 @@ def _get_network(self) -> docker.models.networks.Network:
except docker.errors.NotFound:
_LOGGER.info("Can't find Supervisor network, creating a new network")

ipam_pool = docker.types.IPAMPool(
# IP configuration
ipam_pool_v4 = docker.types.IPAMPool(
subnet=str(DOCKER_NETWORK_MASK),
gateway=str(self.gateway),
iprange=str(DOCKER_NETWORK_RANGE),
)
ipam_pool_v6 = docker.types.IPAMPool(
subnet=str(DOCKER_NETWORK_LINK_LOCAL),
gateway=str(DOCKER_NETWORK_LINK_LOCAL[1]),
iprange=str(DOCKER_NETWORK_LINK_LOCAL),
)

ipam_config = docker.types.IPAMConfig(pool_configs=[ipam_pool])
ipam_config = docker.types.IPAMConfig(pool_configs=[ipam_pool_v4, ipam_pool_v6])

# Create Network
return self.docker.networks.create(
DOCKER_NETWORK,
driver="bridge",
ipam=ipam_config,
enable_ipv6=False,
enable_ipv6=True,
options={"com.docker.network.bridge.name": DOCKER_NETWORK},
)

Expand Down