Configurable IPv4 / IPv6 setting for requests/urllib

Hi All,

Hi All, a network question here related to IPv6 and Telegram witin HA.
I noticed in the docker container logs, that sending Telegram messages from an automation fail (most of the time). Digging into this, seems to be related to the Telegram API not responding on IPv6:

curl -4 -X GET https://api.telegram.org/bot13xxx:AAH-XXX/getUpdates
{"ok":true,"result":[]}

curl -6 -X GET https://api.telegram.org/bot13xxx:AAH-XXX/getUpdates
 -- times out --

It could be that Telegram is blacklisting IPv6 tunnel ranges (like IPTV streaming services are also doing).

Is there a way to configure IPv4/IPv6 for the Telegram messages (or all other requests) in the container (it’s using requests / urllib?)

I do not want to disable IPv6 on the host, as this is required for other containers happily using IPv6.

I have the same problem and I had to disable ipv6 on the host.

Has there been any other better ways to do this ?

As disabling IPv6 on the host is not-done in my case, I worked around it by adding the following to the docker-compose file (main network definition, and addition to services):

networks:
  only_v4:
    driver: bridge
    ipam:
      config:
        - subnet: 172.16.0.0/24


    sysctls:
      - net.ipv6.conf.all.disable_ipv6=1
    networks:
      only_v4:
        ipv4_address: 172.16.0.10
    ports:
      - 8123:8123/tcp
      - 5683:5683/udp
1 Like