开发者

Docker ping ipv6 endpoint

开发者 https://www.devze.com 2022-12-07 19:26 出处:网络
I have a docker heartbeat container up and running from where a connection should be made towards an ipv6 endpoint.

I have a docker heartbeat container up and running from where a connection should be made towards an ipv6 endpoint.

From in the heartbeat container the ping6 command doesn't succeed, from on the host it is working.

In container

sh-4.2$ ping6 ipv6.google.com
PING ipv6.google.com(ams15s32-in-x0e.1e100.net (2a00:1450:400e:809::200e)) 56 data bytes
^C

on vm

[root@myserver myuser]# ping6 ipv6.google.com
PING ipv6.google.com(ams15s30-in-x0e.1e100.net (2a00:1450:400e:807::200e)) 56 data bytes
64 bytes from ams15s30-in-x0e.1e100.net (2a00:1450:400e:807::200e): icmp_seq=1 ttl=120 time=6.55 ms
64 bytes from ams15s30-in-x0e.1e100.net (2a00:1450:400e:807::200e): icmp_seq=2 ttl=120 time=6.60 ms

I've configured the daemon.json file with the subnet and the docker-compose file takes care of the preparation of the ipv6 network

version: "2.2"
services:
  heartbeat:
    image: docker.elastic.co/beats/heartbeat:7.10.1
    container_name: "heartbeat"
    volumes:
      - "./elastic/heartbeat.yml:/usr/share/heartbeat/heartbeat.yml:ro"
      - "./elastic/monitor.d/:/usr/share/heartbeat/monitor.d/:ro"
    networks:
      - beats
networks:
  beats:
    enable_ipv6: true
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 2a02:1800:1e0:408f::806:0/112
        - gateway: 2a02:1800:1e0:408f::806:1

The docker network ls shows the network correctly setup

docker network ls
NETWORK ID     NAME                  DRIVER    SCOPE
...
328408216a9f   deployments_beats     bridge    local
...

And the bridged network is appearing in the ifconfig overview with following info

br-328408216a9f: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.19.0.1  netmask 255.255.0.0  broadcast 172.19.255.255
        inet6 2a02:1800:1e0:408f::806:1 开发者_C百科 prefixlen 112  scopeid 0x0<global>
        inet6 fe80::1  prefixlen 64  scopeid 0x20<link>
        inet6 fe80::42:52ff:fe98:e176  prefixlen 64  scopeid 0x20<link>
        ether 02:42:52:98:e1:76  txqueuelen 0  (Ethernet)
        RX packets 8  bytes 656 (656.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 7  bytes 746 (746.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Anything I've missed during the setup?


You also need to enable ipv6 on the docker engine:

  1. 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.

  2. Reload the Docker configuration file.

     $ systemctl reload docker
    

https://docs.docker.com/config/daemon/ipv6/


Solved by using https://github.com/robbertkl/docker-ipv6nat

Added the container to my docker setup

my daemon.json file in /etc/docker/

{
  "ipv6": true,
  "fixed-cidr-v6": "fd00::/64"
}

which will use the unique local subnet

in my docker-compose I create a ipv6 network

networks:
  beats:
    enable_ipv6: true
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: fd00:1::/80 

note the prefix 1 I'm using in the range

add your container to the network, and it works

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号