====== 21 Set up Wireguard client as Gateway ======
{{drawio>50_dialy:2024:02:diagram1.png}}
| global network| X.X.X.X|
| Wireguard network| 10.10.10.0/24|
| local networdk|192.168.0.0/24|
In this scenario, if you want to connect the local network (192.168.0.0/24) through a local Wireguard as the gateway from a Mobile Wireguard.
===== Configuration on the Wireguard in the Cloud =====
By doing this, the traffic destined for 192.168.0.0/24 will exit through the local Wireguard.
[Interface]
Address = 10.10.10.1/24
ListenPort = 51820
PrivateKey = XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX=
[Peer]
### Mobile
PublicKey = YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY=
PresharedKey = ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ=
AllowedIPs = 10.10.10.2/32
[Peer]
### local
PublicKey = AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=
PresharedKey = BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB=
AllowedIPs = 10.10.10.3/32,192.168.0.0/24
===== Configuration on the Mobile Wireguard =====
On the Mobile side as well, make sure that traffic destined for 192.168.0.0/24 goes through Wireguard.
[Interface]
PrivateKey = CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC=
Address = 10.10.10.2/24
DNS = 8.8.8.8, 8.8.4.4
[Peer]
PublicKey = DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD=
PresharedKey = ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ=
AllowedIPs = 10.0.1.0/24, 192.168.0.0/24
Endpoint = X.X.X.X:51820
{{tag>日記 Wireguard network VPN}}