docker 支持ipv6 (核心要点是ndp需要把docker内的ip全部加入到ndplist中来)
IPv6 with Docker
Estimated reading time: 10 minutes
The information in this section explains IPv6 with the Docker default bridge. This is a bridge
network named bridge
created automatically when you install Docker.
As we are running out of IPv4 addresses the IETF has standardized an IPv4 successor, Internet Protocol Version 6 , in RFC 2460. Both protocols, IPv4 and IPv6, reside on layer 3 of the OSI model.
How IPv6 works on Docker
By default, the Docker daemon configures the container network for IPv4 only. You can enable IPv4/IPv6 dualstack support by running the Docker daemon with the --ipv6
flag. Docker will set up the bridge docker0
with the IPv6 link-local address fe80::1
.
By default, containers that are created will only get a link-local IPv6 address. To assign globally routable IPv6 addresses to your containers you have to specify an IPv6 subnet to pick the addresses from. Set the IPv6 subnet via the --fixed-cidr-v6
parameter when starting Docker daemon:
You can run dockerd
with these flags directly, but it is recommended that you set them in thedaemon.json
configuration file instead. The following example daemon.json
enables IPv6 and sets the IPv6 subnet to 2001:db8:1::/64
.
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64"
}
The subnet for Docker containers should at least have a size of /80
, so that an IPv6 address can end with the container’s MAC address and you prevent NDP neighbor cache invalidation issues in the Docker layer.
By default, --fixed-cidr-v6
parameter causes Docker to add a new route to the routing table, by basically running the three commands below on your behalf. To prevent the automatic routing, set ip-forward
to false
in the daemon.json
file or start the Docker daemon with the --ip-forward=false
flag. Then, to get the same routing table that Docker would create automatically for you, issue the following commands:
$ ip -6 route add 2001:db8:1::/64 dev docker0
$ sysctl net.ipv6.conf.default.forwarding=1
$ sysctl net.ipv6.conf.all.forwarding=1
All traffic to the subnet 2001:db8:1::/64
will now be routed via the docker0
interface.
Note: IPv6 forwarding may interfere with your existing IPv6 configuration: If you are using Router Advertisements to get IPv6 settings for your host’s interfaces, set
accept_ra
to2
using the following command. Otherwise IPv6 enabled forwarding will result in rejecting Router Advertisements.$ sysctl net.ipv6.conf.eth0.accept_ra=2
Every new container will get an IPv6 address from the defined subnet, and a default route will be added on eth0
in the container via the address specified by the daemon option --default-gateway-v6
(or default-gateway-v6
in daemon.json
) if present. The default gateway defaults to fe80::1
.
This example provides a way to examine the IPv6 network settings within a running container.
docker run -it alpine ash -c "ip -6 addr show dev eth0; ip -6 route show"
15: eth0: <BROADCAST,UP,LOWER_UP> mtu 1500
inet6 2001:db8:1:0:0:242:ac11:3/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::42:acff:fe11:3/64 scope link
valid_lft forever preferred_lft forever
2001:db8:1::/64 dev eth0 proto kernel metric 256
fe80::/64 dev eth0 proto kernel metric 256
default via fe80::1 dev eth0 metric 1024
In this example, the container is assigned a link-local address with the subnet /64
(fe80::42:acff:fe11:3/64
) and a globally routable IPv6 address (2001:db8:1:0:0:242:ac11:3/64
). The container will create connections to addresses outside of the 2001:db8:1::/64
network via the link-local gateway at fe80::1
on eth0
.
Often servers or virtual machines get a /64
IPv6 subnet assigned (e.g.2001:db8:23:42::/64
). In this case you can split it up further and provide Docker a /80
subnet while using a separate /80
subnet for other applications on the host:
In this setup the subnet 2001:db8:23:42::/64
with a range from 2001:db8:23:42:0:0:0:0
to 2001:db8:23:42:ffff:ffff:ffff:ffff
is attached to eth0
, with the host listening at 2001:db8:23:42::1
. The subnet 2001:db8:23:42:1::/80
with an address range from 2001:db8:23:42:1:0:0:0
to 2001:db8:23:42:1:ffff:ffff:ffff
is attached to docker0
and will be used by containers.
Using NDP proxying
If your Docker host is the only part of an IPv6 subnet but does not have an IPv6 subnet assigned, you can use NDP proxying to connect your containers to the internet via IPv6. If the host with IPv6 address 2001:db8::c001
is part of the subnet 2001:db8::/64
and your IaaS provider allows you to configure the IPv6 addresses 2001:db8::c000
to 2001:db8::c00f
, your network configuration may look like the following:
$ ip -6 addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qlen 1000
inet6 2001:db8::c001/64 scope global
valid_lft forever preferred_lft forever
inet6 fe80::601:3fff:fea1:9c01/64 scope link
valid_lft forever preferred_lft forever
To slit up the configurable address range into two subnets 2001:db8::c000/125
and 2001:db8::c008/125
, use the following daemon.json
settings. The first subnet will be used by non-Docker processes on the host, and the second will be used by Docker.
{
"ipv6": true,
"fixed-cidr-v6": "2001:db8::c008/125"
}
The Docker subnet is within the subnet managed by your router and connected to eth0
. All containers with addresses assigned by Docker are expected to be found within the router subnet, and the router can communicate with these containers directly.
When the router wants to send an IPv6 packet to the first container, it transmits a neighbor solicitation request, asking “Who has 2001:db8::c009
?” However, no host on the subnet has the address; the container with the address is hidden behind the Docker host. The Docker host therefore must listen for neighbor solicitation requests and respond that it is the device with the address. This functionality is called the NDP Proxy and is handled by the kernel on the host machine. To enable the NDP proxy, execute the following command:
$ sysctl net.ipv6.conf.eth0.proxy_ndp=1
Next, add the container’s IPv6 address to the NDP proxy table:
$ ip -6 neigh add proxy 2001:db8::c009 dev eth0
From now on, the kernel answers neighbor solicitation addresses for this address on the device eth0
. All traffic to this IPv6 address is routed through the Docker host, which will forward it to the container’s network according to its routing table via the docker0
device:
$ ip -6 route show
2001:db8::c008/125 dev docker0 metric 1
2001:db8::/64 dev eth0 proto kernel metric 256
You have to execute the ip -6 neigh add proxy ...
command for every IPv6 address in your Docker subnet. Unfortunately there is no functionality for adding a whole subnet by executing one command. An alternative approach would be to use an NDP proxy daemon such as ndppd.
docker 支持ipv6 (核心要点是ndp需要把docker内的ip全部加入到ndplist中来)的更多相关文章
- docker支持ipv6
方法 方法一.Pv6地址 不为容器中的服务特别分配IPv6地址. 只要Docker把外部的IPv6地址端口映射到容器的IPv4端口上,随后访问主机的IPv6相应端口即可. 方法二.为Docker网络分 ...
- 高级网络功能(Docker支持的网络定制配置)
网络的高级知识,包括网络的启动和配置参数.DNS的使用配置.容器访问和端口映射的相关实现. 在一些具体场景中,Docker支持的网络定制配置,通过Linux命令来调整.补充.甚至替换Docker默认的 ...
- 阿里云开源镜像站支持IPv6访问
阿里云开源镜像站在国内企业镜像站中率先支持IPv6访问! 点击立即试用https://developer.aliyun.com/mirror/ 同时基于阿里云OpenSearch的搜索能力,开源镜像站 ...
- Java生鲜电商平台-SpringCloud微服务架构中核心要点和实现原理
Java生鲜电商平台-SpringCloud微服务架构中核心要点和实现原理 说明:Java生鲜电商平台中,我们将进一步理解微服务架构的核心要点和实现原理,为读者的实践提供微服务的设计模式,以期让微服务 ...
- 最佳实践:阿里云VPC、ECS支持IPv6啦!
12月6日,阿里云宣布为企业提供全栈IPv6解决方案. 阿里云专有网络VPC.云服务器ECS,作为阿里云的核心产品,也于2018年11月底上线双栈VPC.双栈ECS,目前正在对外公测中. 那么如何在阿 ...
- Android应用框架中的四个核心要点
Android应用框架中的四个核心要点:活动(Activity).消息(Intent).视图(View).任务(Task) (一)活动Activity Android系统内部有专门的Activity堆 ...
- nfs 支持ipv6
mount 一个ipv6 nfs 项目在docker里mount 一个nfs来读写,而现在需要支持ipv6,所以先写了各小demo,最后成功mount,这里记录一下 #include <sys/ ...
- 网络支持IPV6地址测试校验与思考
概述 大背景:随着移动端的快速扩张,互联网的规模越来越广阔,早于2011年耗尽的IPV4地址越来越无法满足互联网的网络地址需求,IPV6地址推广进入快车道.实际情况:近期公司应上级部门邀请对公司的主域 ...
- iOS 支持 IPv6
苹果的规定:2016年6月1日提交到App Store必须支持IPv6-only网络. 官方文档:https://developer.apple.com/library/mac/documentati ...
随机推荐
- python selenium 定制启动Chrome的选项注意事项(十九)
自动化测试的时候为了避免每个case均需要登录的操作,所以把登录后的cookie信息保存下来,在有效期内使用cookie的方式实现登录操作,为了避免展现太多的登录操作,需要通过设置浏览器的option ...
- G2 绘制混合图例 demo
G2 绘制混合图例 demo import G2 from '@antv/g2'; import DataSet from '@antv/data-set'; // G2 对数据源格式的要求,仅仅是 ...
- 分享一个生成反遗忘复习计划的java程序
想必这个曲线大家都认识,这是遗忘曲线,展示人的记忆会随着时间的延长慢慢遗忘的规律,同时还展示了如果我们过一段时间复习一次对遗忘的有利影响. 道理大家都懂,关键怎么做到? 靠在本子上记下今天我该复习哪一 ...
- The 'INFORMATION_SCHEMA.GLOBAL_STATUS' feature is disabled; see the documentation for 'show_compatibility_56'
--从mysql5.7.6开始information_schema.global_status已经开始被舍弃,为了兼容性,此时需要打开 show_compatibility_56 mysql> ...
- Linux第八章:文件,文件系统的压缩,打包备份
压缩:gzip -v 文件名 1:压缩后成 文件名.gz 的压缩文件,原文件消失 2:压缩的文件可以直接使用zcat 文件名.gz 读取里面的内容 解压缩: gunzip 文件名.gz 替 ...
- 知识点:Mysql 基本用法之存储过程
存储过程 一. 介绍 存储过程包含了一系列可执行的sql语句,存储过程存放于MySQL中,通过调用它的名字可以执行其内部的一堆sql 使用存储过程的优点: 用于替代程序写的SQL语句,实现程序与sql ...
- 1-hadoop、mr
1.HDFS的优缺点: 优点: ① 高容错 ② 可扩展 ③ 适合大文件存储 ④ 可构建在廉价的机器上 缺点: ① 高延迟 ② 文件不能修改 ③ 不适合小文件存储 2.HDFS架构(类似于文件系统): ...
- Zookeeper的一致性协议:Zab
Zookeeper使用了一种称为Zab(Zookeeper Atomic Broadcast)的协议作为其一致性复制的核心,据其作者说这是一种新发算法,其特点是充分考虑了Yahoo的具体情况: ...
- Entity Frame Code First 简易教程
简介 什么是ORM 搭建Entity FrameWork CodeFirst应用 数据库迁移 表属性常见配置 Entity FrameWork 一对多.多对多 一.简介 Entity Framewor ...
- BBS(第一天)项目之 注册功能实现通过forms验证与 前端ajax请求触发查询数据库判断用户是否存在的功能实现
1.BBS项目之注册功能通过forms验证 from django import forms from blog.models import User from django.contrib.auth ...