View previous topic :: View next topic |
Author |
Message |
erg_samowzbudnik Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/987013275957f01a539c9.jpg)
Joined: 09 Sep 2011 Posts: 229 Location: European sticks
|
Posted: Tue Mar 03, 2020 4:01 pm Post subject: Wireguard server and/or iptables issue [SOLVED] |
|
|
I'm setting up wireguard server on a remote RPi to connect to with a laptop. Both run Gentoo. I can already reach the wireguard server (tcpdump shows a packet arrive) but then connection instantly dies on a client and I need to 'wg-quick down wg0' to get network back (on the client).
RPi runs iptables. So perhaps I'm having an issue with its' rules? I am not too good with networking/iptables so I've been trying to copy/paste rules into /etc/wireguard/wg0.conf ... I've tried with none, explicitly opening port used by wireguard as well as each of those two sets below:
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
but connection still dies as soon as I bring up wg0 on the client.
Edit:
servers' /etc/wireguard/wg0.conf
Code: | [Interface]
Address = 10.0.0.1/24
ListenPort = 3000
PrivateKey = yyy
PostUp = iptables -A FORWARD -i %i -j ACCEPT; iptables -A FORWARD -o %i -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i %i -j ACCEPT; iptables -D FORWARD -o %i -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
[Peer]
PublicKey = xxx
AllowedIPs = 10.0.0.2/32 |
clients' /etc/wireguard/wg0.conf
Code: | [Interface]
PrivateKey = xxxxx
Address = 10.0.0.2/32
[Peer]
PublicKey = yyy
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 18.xx.xx.xx:3000 |
Last edited by erg_samowzbudnik on Sat Mar 07, 2020 3:53 pm; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
erg_samowzbudnik Apprentice
![Apprentice Apprentice](/images/ranks/rank_rect_2.gif)
![](images/avatars/987013275957f01a539c9.jpg)
Joined: 09 Sep 2011 Posts: 229 Location: European sticks
|
Posted: Sat Mar 07, 2020 3:53 pm Post subject: |
|
|
The issue was resolved by setting net.ipv4.ip_forward=1 in /etc/sysctl.conf |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|