masipcat / wireguard-go-docker

Wireguard docker image
https://hub.docker.com/r/masipcat/wireguard-go
GNU General Public License v3.0
182 stars 42 forks source link

Fixed an issue with wg0.conf #14

Closed hiiro74 closed 4 years ago

hiiro74 commented 4 years ago

There seems to be a problem with PostDown not removing iptables setting so I made changes to it on my end. Below is what I modified.

Address = 10.99.0.1/24
ListenPort = 51820
PostUp = wg set wg0 private-key /etc/wireguard/privatekey && iptables -t nat -A POSTROUTING -s 10.99.0.0/24 -o eth0 -j MASQUERADE
PostDown = iptables -t nat -D POSTROUTING -s 10.99.0.0/24 -o eth0 -j MASQUERADE

# [Peer]
# PublicKey = <client's publickey>
# AllowedIPs = 10.99.0.2/32
masipcat commented 4 years ago

Which image tag are you using? latest or 0.0.20200320? If it's the first one, can you try with 0.0.20200320 ?

hiiro74 commented 4 years ago

I cloned the git repository master branch which has sample configs under wireguard folder. The docker hub images dont have a default configuration.

The Kubernetes wireguard.yaml shown in the Overview on docker hub may also has the same issue I believe but I have yet to test it. Looking at wg0.conf its also the same as the one as the master branch on the git repository. The PostUp iptables should be almost identical to PostDown.

  wg0.conf: |
    [Interface]
    Address = 10.33.0.1/24
    ListenPort = 51820
    PostUp = wg set wg0 private-key /etc/wireguard/privatekey && iptables -t nat -A POSTROUTING -s 10.33.0.0/24 -o eth0 -j MASQUERADE
    PostDown = iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE

    # [Peer]
    # PublicKey =
    # AllowedIPs = 10.33.0.2/32

should be changed to

  wg0.conf: |
    [Interface]
    Address = 10.33.0.1/24
    ListenPort = 51820
    PostUp = wg set wg0 private-key /etc/wireguard/privatekey && iptables -t nat -A POSTROUTING -s 10.33.0.0/24 -o eth0 -j MASQUERADE
    PostDown = iptables -t nat -D POSTROUTING -s 10.33.0.0/24 -o eth0 -j MASQUERADE

    # [Peer]
    # PublicKey =
    # AllowedIPs = 10.33.0.2/32
masipcat commented 4 years ago

Oh I see. I'll be happy to merge a PR with these changes. But I can fix it for you if you want. Let me know and thank you for reporting :)

hiiro74 commented 4 years ago

no problem, just informing you about it. You can just fix it since its just a very minor issue =)