mediaserver-docker icon indicating copy to clipboard operation
mediaserver-docker copied to clipboard

Wireguard VPN port forward with Mullvad not working as expected

Open sourea opened this issue 5 years ago • 2 comments

I opened up port on my wireguard key as described in https://mullvad.net/en/help/port-forwarding-and-mullvad/

I changed the exposed port on one of the services in the compose file to the port mullvad allocated. I am able to access the service over the specified port on the local network. However, I am unable to reach the same using the wg interface's public ip address and port combination. I checked an online port tester tool as well and the port shows as closed.

Is there any specific configuration that needs to be set to enable port forwarding seamlessly?

sourea avatar Aug 20 '20 00:08 sourea

This is probably a dumb question but have you forwarded the port on your router?

ghostserverd avatar Aug 20 '20 04:08 ghostserverd

I have forwarded the port on my router. It seems like it only works if the service inside the docker container uses the same port number as the number exposed by mullvad on the key. For example I setup a simple nginx hello container (https://hub.docker.com/r/nginxdemos/hello/) and mapped my mullvad port (Say 12345) to 80 inside the container i.e

service:
  hello:
    network_mode: service:wireguard

  wireguard:
    image: ghostserverd/wireguard
    ports:
      - 12345:80 # does not work

Then I tried a netcat inside another container but mapped the mullvad port to the same one inside the container this time

service:
  netcat:
    network_mode: service:wireguard

  wireguard:
    image: ghostserverd/wireguard
    ports:
      - 12345:12345 # works

By making netcat listen on the same port, I was able to see that it was open with an online port scanning tool on mullvad's allocated public ip. I am not sure if its something to do with how the iptables rules are setup or not so far

sourea avatar Aug 21 '20 03:08 sourea