方法

方法一、Pv6地址

不为容器中的服务特别分配IPv6地址。

只要Docker把外部的IPv6地址端口映射到容器的IPv4端口上,随后访问主机的IPv6相应端口即可。

方法二、为Docker网络分配IPv6地址

(1)Docker daemon默认只支持IPv4地址,通过在运行Docker时增加--ipv6参数可以使其同时支持ipv4和ipv6地址。

(2)此时容器仅获得了本地ipv6地址,如果要获得全局ipv6地址,必须确保机器有至少/80的地址段,通过在运行Docker时增加--fixed-cidr-v6参数为其配置ipv6子网。

该参数会在路由表中添加一条路由,相当于执行了一下命令:

$ ip -6 route add 2001:db8:1::/64 dev docker0

$ sysctl net.ipv6.conf.default.forwarding=1

$ sysctl net.ipv6.conf.all.forwarding=1

随后,所有路由往2001:db8:1::/64的流量都会通过docker0接口路由

(3)除了在运行时添加参数,还可以直接编辑/etc/docker/daemon.json文件,加入以下内容:

{

"ipv6": true,

"fixed-cidr-v6": "2001:db8:1::/64"

}

其中2001:db8:1::/64是IPv6地址段。

systemctl reload docker

(4)使用systemctl restart docker命令重启Docker。

(5)使用ifconfig命令查看分配到Docker网络的IPv6地址段

(6)完成了上面的配置之后,无需特意配置,只需正常建立容器,即可为容器分配IPv6地址。可以使用“docker inspect容器名”查看容器的IP地址。

官网教程

启用ipv6

Edit /etc/docker/daemon.json, set the ipv6 key to true and the fixed-cidr-v6 key to your IPv6 subnet. In this example we are setting it to 2001:db8:1::/64.

{
"ipv6": true,
"fixed-cidr-v6": "2001:db8:1::/64"
} Save the file.
Reload the Docker configuration file. $ systemctl reload docker

启用外部转发

https://docs.docker.com/netwo...

Enable forwarding from Docker containers to the outside world

By default, traffic from containers connected to the default bridge network is not forwarded to the outside world. To enable forwarding, you need to change two settings. These are not Docker commands and they affect the Docker host’s kernel.

Configure the Linux kernel to allow IP forwarding.

$ sysctl net.ipv4.conf.all.forwarding=1

Change the policy for the iptables FORWARD policy from DROP to ACCEPT.

$ sudo iptables -P FORWARD ACCEPT

These settings do not persist across a reboot, so you may need to add them to a start-up script.

创建自己的 ip6 网卡

开启ip6网卡后,只有 bridge 网卡,会自动启用 ip6

创建 user ip6 网卡

docker network create -d bridge --subnet 172.30.20.0/24 mynet2  --ipv6

docker network create -d bridge --ipv6 --subnet "fd00:daad:beee:1::/64" --gateway="fd00:daad:beee::1" --subnet=172.18.0.0/16 --gateway=172.18.0.1 myNet

# 需要仿照 bridge 的信息进行配置
docker inspect 37da
{
"Subnet": "2001:db8:1::/64",
"Gateway": "2001:db8:1::1"
} docker network create -d bridge --ipv6 --subnet "2001:db8:2::/64" --gateway="2001:db8:2::1" --subnet=172.30.20.0/24 mynet2 绑定自己的容器到 自定义的网卡
docker run -d -p 30080:80 --net mynet2 nginx $ sysctl net.ipv6.bindv6only = 1
$ sysctl net.ipv6.conf.default.forwarding=1
$ sysctl net.ipv6.conf.all.forwarding=1 docker network create -d bridge --ipv6 --subnet "2001:db8:3::/64" --gateway="2001:db8:3::1" --subnet=172.30.30.0/24 mynet3
docker run -d -p 30080:80 --net mynet3 nginx

如果需要 直接根据 ip 访问容器 需要 增加 路由配置

ip -6 route 查看路由中转

# 定向 2001:db8:1::/64 ip6 到 docker0 网卡设备
ip -6 route add 2001:db8:1::/64 dev docker0

暂停 删除所有

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

docker支持ipv6的更多相关文章

  1. docker 支持ipv6 (核心要点是ndp需要把docker内的ip全部加入到ndplist中来)

    IPv6 with Docker Estimated reading time: 10 minutes The information in this section explains IPv6 wi ...

  2. nfs 支持ipv6

    mount 一个ipv6 nfs 项目在docker里mount 一个nfs来读写,而现在需要支持ipv6,所以先写了各小demo,最后成功mount,这里记录一下 #include <sys/ ...

  3. 阿里云开源镜像站支持IPv6访问

    阿里云开源镜像站在国内企业镜像站中率先支持IPv6访问! 点击立即试用https://developer.aliyun.com/mirror/ 同时基于阿里云OpenSearch的搜索能力,开源镜像站 ...

  4. iOS 支持 IPv6

    苹果的规定:2016年6月1日提交到App Store必须支持IPv6-only网络. 官方文档:https://developer.apple.com/library/mac/documentati ...

  5. linux centos6.5支持ipv6

    1.用ifconfig查看有没有inet6 addr,我的这个已经支持了,如果不支持请看第二步. 2.vim /etc/sysconfig/network 把这句改成:NETWORKING_IPV6= ...

  6. iOS应用支持IPV6,就那点事儿

    原文连接   果然是苹果打个哈欠,iOS行业内就得起一次风暴呀.自从5月初Apple明文规定所有开发者在6月1号以后提交新版本需要支持IPV6-Only的网络,大家便开始热火朝天的研究如何支持IPV6 ...

  7. iOS应用支持IPV6

    一.IPV6-Only支持是啥? 首先IPV6,是对IPV4地址空间的扩充.目前当我们用iOS设备连接上Wifi.4G.3G等网络时,设备被分配的地址均是IPV4地址,但是随着运营商和企业逐渐部署IP ...

  8. 用尽洪荒之力解决Apple Store ipv6审核通关---linux服务器支持ipv6

         强势的库克时代到来,苹果开启了强制IPV6审核,大家也知道中国现在的情况,除了教育网实验性的支持IPV6,ISP运营商还不支持,想必大家都陆陆续续的遭受到了苹果无情的拒绝,以前开个加急,审核 ...

  9. iOS 上线因iPv6被拒,查询服务器是否支持iPv6,mac设置iPv6网络,手机测试iPv6

    一. iOS----如何检查域名是否支持ipv6 iOS----------如何检查域名是否支持ipv6 1.检查你所用到的库,像af 3.0以上什么的(不用改),其他的库自己去搜下是否支持ipv6吧 ...

随机推荐

  1. 蕞短鹭(artskjid) (⭐通信题/模拟⭐)

    文章目录 题面(过于冗长,主要是对通信题的一些解释) 题解 1.通信题什么意思 2.此题题解 CODE 实现 题面(过于冗长,主要是对通信题的一些解释) 题解 1.通信题什么意思 并不是两个程序同时跑 ...

  2. 小A的树 - 树形DP

    题面 1 9 4 4 1 1 5 1 2 3 2 3 6 6 7 6 8 9 6 0 1 0 1 0 0 1 0 1 3 2 7 3 4 0 9 5 YES YES NO NO 题解 n <= ...

  3. 2020牛客NOIP赛前集训营-提高组(第二场)- B.包含 (FWT)

    题面 题解 这题就是个快速沃尔什变换的模板题,输入ai时,令s[ai]=1,对s[]做一遍DWT_AND(s)(快速沃尔什正变换,按位与),然后直接访问s[x]完事. #include<map& ...

  4. 第五十七篇:webpack打包发布

    好家伙,到了打包发布这一步了 1.配置打包命令: 在package.json 文件的 scripts 节点下,新增 build 命令如下: "scripts": { "d ...

  5. docker注册中心相关操作

    相关命令详解 (1)push推送 将镜像推送到由其名称或标签指定的仓库中.与pull命令相对. [root@docker ~]# docker push --help Usage: docker pu ...

  6. 仙人指路,引而不发,Go lang1.18入门精炼教程,由白丁入鸿儒,Golang中New和Make函数的使用背景和区别EP16

    Golang只有二十五个系统保留关键字,二十几个系统内置函数,加起来只有五十个左右需要记住的关键字,纵观编程宇宙,无人能出其右.其中还有一些保留关键字属于"锦上添花",什么叫锦上添 ...

  7. [第二章 web进阶]XSS闯关-1

    定义:跨站脚本(Cross_Site Scripting,简称为XSS或跨站脚本或跨站脚本攻击)是一种针对网站应用程序的安全漏洞攻击技术,是代码注入的一种.它允许恶意用户将代码注入网页,其他用户浏览网 ...

  8. [MRCTF2020]Ez_bypass WP

    首先打开页面 他提示说f12里面有东西,于是直接ctrl+u 查看源代码 I put something in F12 for you include 'flag.php'; $flag='MRCTF ...

  9. 10.Ceph 基础篇 - RGW 高可用

    文章转载自:https://mp.weixin.qq.com/s?__biz=MzI1MDgwNzQ1MQ==&mid=2247485316&idx=1&sn=d3a6be41 ...

  10. K8S ingress控制器

    文章转载自: K8S ingress控制器 (一)https://blog.51cto.com/u_13760351/2728917 K8S ingress控制器 (二)https://blog.51 ...