Score:0

Configure Wireguard to access LAN but don't route internet traffic through VPN

cn flag

Currently I have access to LAN through wireguard and internet. How to configure wg0 to have access to LAN but don't route internet traffic through VPN ?

My current config (wg0):

Address = 10.0.0.1/32
ListenPort = 51820
PrivateKey = {key}
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
MTU = 1500

[Peer]
PublicKey = {key}
PresharedKey = {key}
AllowedIPs = 10.0.0.2/32

[Peer]
PublicKey = {key}
PresharedKey = {key}
AllowedIPs = 10.0.0.3/32

[Peer]
PublicKey = {key}
PresharedKey = {key}
AllowedIPs = 10.0.0.4/32

[Peer]
PublicKey = {key}
PresharedKey = {key}
AllowedIPs = 10.0.0.5/32

[Peer]
PublicKey = {key}
PresharedKey = {key}
AllowedIPs = 10.0.0.6/32

Example client config:

[Interface]
PrivateKey = {key}
ListenPort = 51820
Address = 10.0.0.4/32
DNS = 1.1.1.1, 1.0.0.1


[Peer]
PublicKey = {key}
PresharedKey = {key}
AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = 11.11.111.98:51820
dummyuser avatar
uy flag
That's a server config. Please post your client config, too. whats in the parameter AllowedIPs of your client? please remove keys.
Reckos avatar
cn flag
@dummyuser edited. Please check now.
dummyuser avatar
uy flag
The parameter `AllowedIPs` in your client config defines which IPs should be reached via VPN right now you you send all IPs into the VPN. You ned to know which IPs to be reached via VPN e.G. `AllowedIPs = 172.16.1.0/24,192.168.1.0/24,192.168.2.0/24,192.168.4.0/24,2022:beef:db8::/64`
Reckos avatar
cn flag
@dummyuser please explain. I don't understand what should be in 'AllowedIPs'
dummyuser avatar
uy flag
You do not want to route internet traffic through your VPN, correct? In terms of IP Addresses “Internet Traffic” means all destination IPs. Your current definition of `AllowedIPs` in the client config means route all destination IPs (=all Internet Traffic) through the VPN. 1) Define exactly which destination IPs to be routed though your VPN and adopt the value of the `AllowedIPs` in you client config. 2) AllowedIPs needs a comma separated list of target networks to be reached through the VPN See manpage of wireguard of samples for more info
Reckos avatar
cn flag
ok fixed. Works
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.