0

In an LXC container I have Wireguard installed and the client connects normally and I see the port and the information, but when I try to curl to localhost (127.0.0.1) or to the local ip (192.168.1.180) it doesn't connect.

192.168.1.180 (Host IP) 10.7.0.2 (IP)

10.7.0.2:6060 <-> 192.168.1.180:6060

curl -I 10.7.0.2:6060

-Resolve OK --

curl -I 127.0.1:6060 (OR) curl -I 192.168.1.180:6060

Responde unreachable

My IPtables rules:

iptables -A FORWARD -i eth0 -j ACCEPT;
iptables -t nat -A PREROUTING -p tcp --dport 6060:6060 -j DNAT --to-destination 10.7.0.2;
iptables -w -t nat -A POSTROUTING -o eth0 -j MASQUERADE;

IPv4 Forward is active:

#sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

Server Wireguard Config:

root@wiretest:/etc/wireguard# cat wg0.conf
# Do not alter the commented lines
# They are used by wireguard-install
# ENDPOINT asd.demo.net

[Interface]
Address = 10.7.0.1/24
PrivateKey = CI0heA/1InAo........
ListenPort = 51820
        
# BEGIN_PEER nodotest
[Peer]
PublicKey = y1t+k9cR06F7/y6ANJtEx.......
PresharedKey = +Tya8VsxbB3i9hkIRf......
AllowedIPs = 10.7.0.2/32
# END_PEER nodotest
root@wiretest:/etc/wireguard#

Client Config:

root@wiredocker:/etc/wireguard# cat wg0.conf
[Interface]
Address = 10.0.0.2/24
DNS = 8.8.8.8
PrivateKey = +GLTuJnydedy2QMvTj5SGdr......

[Peer]
PublicKey = qlNPgT7Fwbjmexq09EVF........
PresharedKey = +Tya8VsxbB3i9hkIR......
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = asd.demo.net:51820
PersistentKeepalive = 25
root@wiredocker:/etc/wireguard# 

Server IPTables List:

# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     udp  --  anywhere             anywhere             udp dpt:51823

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere             state RELATED,ESTABLISHED
ACCEPT     all  --  10.7.0.0/24          anywhere            

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
 

Thanks !

  • Please don't use Docker when doing any troubleshooting involving networking not directly related to Docker. Have it removed or completely disabled and reboot. Running Docker never helps (eg: https://serverfault.com/questions/963759/docker-breaks-libvirt-bridge-network) – A.B Jul 17 '21 at 10:04
  • i have the same problem without Docker :S – victorelec14 Jul 17 '21 at 10:13
  • Maybe but you might miss a working configuration later because of it – A.B Jul 17 '21 at 10:17

0 Answers0