Score:1

How to use WireGuard LAN only?

az flag

I have installed WireGuard (using wg-easy Docker image) on Virtual Machine in cloud. And all works fine, I can create clients and connect.

WireGuard have subnet 10.8.0.0/24, and all connected clients have IP from this subnet.

But the problem is all my internet traffic goes through IP address of this VM.

When I connected to WireGuard, I want to ping other clients (for example I have ip 10.8.0.2 and other computer has 10.8.0.3 - and we can ping each other), but my internet traffic should not go through WireGuard - I want to keep IP address from my ISP.

How can I configure WireGuard for this?

Here is default config that I have:

# Server
[Interface]
PrivateKey = XXX
Address = 10.8.0.1/24
ListenPort = 51820
PreUp =
PostUp =  iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE; iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT; iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT;
PreDown =
PostDown =

Is there anything I should add or edit in this config? I am not good at understanding all this iptables stuff, so any cli command examples or config examples will be great.

ar flag
This sounds like an [XY problem](https://en.wikipedia.org/wiki/XY_problem). You should not need WireGuard (or any other VPN protocol) for communicating between devices within your own LAN. A VPN is typically used for two different purposes, enterprise (employer provided) VPN allows one to access the company LAN. Consumer grade VPN allows anonymous access to the Internet. WireGuard may not be the right tool for what you want to do.
myuce avatar
cn flag
The comment above should be "the answer" :)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.