How to Ensure fixed IPv6 Address for Husarnet VPN in Docker Container

Hi,

I’ve integrated Husarnet VPN as a sidecar image into my Docker Compose setup. However, each time I stop and rebuild the Docker container, Husarnet assigns a new IPv6 address to the container. This requires me to update all configurations related to the IPv6 address, including FastDDS and other dependencies.

Is there a way to ensure that the IPv6 address assigned by Husarnet VPN to the Docker container remains fixed, even after stopping and rebuilding the container?

Thank you!

Hello,

yes, of course there is. Husarnet identity is stored in /var/lib/husarnet. You need to set this folder as a Docker volume like this:

  husarnet:
    image: husarnet/husarnet:latest

    volumes:
      # This will persist your Husarnet Client keys, thus IP of the container
      # will be stable/the same between (re)boots.
      # Feel free to choose any volume storage method of your liking
      - ./husarnet-config:/var/lib/husarnet

See more at:

Best regards,
Szymon

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.