Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save suhlig/87c61b656cf12e34d3d481a3521204a5 to your computer and use it in GitHub Desktop.
Save suhlig/87c61b656cf12e34d3d481a3521204a5 to your computer and use it in GitHub Desktop.
Wireguard Site-2-Site VPN
# This is the main router in the cloud
[Interface]
Address = 10.0.0.1/24
ListenPort = 51820
PrivateKey = <PrivateKey>
# Router location A
[Peer]
PublicKey = <PublicKey>
AllowedIPs = 10.0.0.2/32, 192.168.111.0/24
# Router location B
[Peer]
PublicKey = <PublicKey>
AllowedIPs = 10.0.0.3/32, 192.168.155.0/24
# External client 1 (Laptop)
[Peer]
PublicKey = <PublicKey>
AllowedIPs = 10.0.0.4/32
# External client (Laptop)
[Interface]
PrivateKey = <PrivateKey>
Address = 10.0.0.4/32
[Peer]
PublicKey = <PublicKey_Cloud_Router>
AllowedIPs = 10.0.0.0/24, 192.168.155.0/24, 192.168.111.0/24
Endpoint = cloud-router.example.com:51820
PersistentKeepalive = 60
# Router location A
[Interface]
PrivateKey = <PrivateKey>
Address = 10.0.0.2/32
PreUp = sysctl -w net.ipv4.ip_forward=1
PostUp = iptables --table mangle --append PREROUTING --in-interface %i --jump MARK --set-mark 0x30
PostUp = iptables --table nat --append POSTROUTING ! --out-interface %i --match mark --mark 0x30 --jump MASQUERADE
PostDown = iptables --table mangle --delete PREROUTING --in-interface %i --jump MARK --set-mark 0x30
PostDown = iptables --table nat --delete POSTROUTING ! --out-interface %i --match mark --mark 0x30 --jump MASQUERADE
[Peer]
PublicKey = <PublicKey_Cloud_Router>
AllowedIPs = 10.0.0.0/24, 192.168.155.0/24
Endpoint = cloud-router.example.com:51820
PersistentKeepalive = 60
# Router location B
[Interface]
Address = 10.0.0.3/32
PrivateKey = <PrivateKey>
PreUp = sysctl -w net.ipv4.ip_forward=1
PostUp = iptables --table mangle --append PREROUTING --in-interface %i --jump MARK --set-mark 0x30
PostUp = iptables --table nat --append POSTROUTING ! --out-interface %i --match mark --mark 0x30 --jump MASQUERADE
PostDown = iptables --table mangle --delete PREROUTING --in-interface %i --jump MARK --set-mark 0x30
PostDown = iptables --table nat --delete POSTROUTING ! --out-interface %i --match mark --mark 0x30 --jump MASQUERADE
[Peer]
PublicKey = <PublicKey_Cloud_Router>
AllowedIPs = 10.0.0.0/24, 192.168.111.0/24
Endpoint = cloud-router.example.com:51820
PersistentkeepAlive = 60
Display the source blob
Display the rendered blob
Raw
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="611px" height="451px" viewBox="-0.5 -0.5 611 451" content="&lt;mxfile host=&quot;app.diagrams.net&quot; modified=&quot;2021-11-13T19:56:56.704Z&quot; agent=&quot;5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36&quot; etag=&quot;vBimgXDC3uEbqOkWjgK5&quot; version=&quot;15.0.6&quot; type=&quot;device&quot;&gt;&lt;diagram id=&quot;IOsk0jZRTr3pCswH6za-&quot; name=&quot;Page-1&quot;&gt;1Vptc5s4EP41/mgPQoDtj00a927mrteZtL2PGRkUUCsjRsjG7q+vAAHitaSNMZnMOHi10opndx92hRfw/nD+wFEU/Ms8TBem4Z0X8P3CNB3Lkp+p4JILLNvIBT4nXi4CleCR/MBKWKgdiYfjmqJgjAoS1YUuC0PsipoMcc6Sutozo3WrEfKVRaMSPLqI4pba/8QTQS7d2Jr2X5j4QWEZGGrkgAplJYgD5LFEE8GHBbznjIn86nC+xzTFrsAln7frGS03xnEoOiZ8iTH/b/8txcQ0KNpLt2RKLmVHb8nZUWCeL0FJ+L0AfZX+yaV3pvJbYS5h67+Tr1+cj8b26Jgfd0niPS3N8jbK7cXiUkAnbYQeTucbC3iXBETgxwi56WgiY0XKAnFIdwXkZW7thLnA594bBJq9D5gdsOAXqaImmGuFtAo1R31NKr+BwhmB5rNCD6lQ8cuVKzTlhbrF4quGb7eDOhEDpgqGCibsyYBTXxkXAfNZiOhDJb2rA1np/MNYpOD7hoW4qOxBR8G6wE0NDUMr98WO3MUDNwBVDiLuYzGg53S7imOKBDnV9/EC4FlHRKtAjU5WLYoL+aA79G22I3gC12C6z0ghjXwiaUeK3CM/ZUum48+E0ntGGc92BD0bbzx5n3ex4Ow71kY25h46zm2cbf6hs9XUT4yEQstnu57PwGokar4vNasKmXeco4umFqUKcb+dct3CzqbBvA19CAf15UW+gyp+S0x6uIRpPNLH2zljLylzJaYsXL4bEd5wVvy8qcNmWnPkZ/jG+dkambLr6/Dz2Ojdj4hea1bRa72F8C0ehi8K39rz5o9j+aYPLHuiB1aP38Y5SW3yhOgR6xWM5jQUR3kz80zOqTPuIsyJtI5T7KQJ2f3gT5VIxx9R4ofy2pXgZWNl35E61ENxUHo3lvlCQv9z5lkoBeSQdUPF//fk4Ms7pERm6w65KTJPHuFyZyyFYUdRJFj05FIiba3ik/86mQaN9cpu5JrdyrVCpKea/fJUG+cyp+UysDVXwNmsAAArQ+uX9MzL/ZS7IEqFWe81CVs5dbIqSxadrJwOstpcC8F1P4K2PUcErdlBCOw3XpuAscXJlZrHvuIkYLFYoqUxoiYB8ypKGjVJebg2p5oEbG8RtrPuq8fmwXX6asvsqWSLJfL9t/rq9kJgmgbdvm2D3kcb9XOm1inqmPMnc7hDl8QgJuER0DhqKY/fNSJZd/AIfBUe+QXAsAdgOAbgYb6eDGB7zgBbPQCPegWwnQfAzZw3QbtluBnA+guV33/bAo2ZQN2kY7Mdy9vpodYaMtCCut6t/RpqMA+om7wMjY4Cz7gd1rJ168e60dcNA27OA/AmT3cC3lVRTxfc7XqjPTiM9UyLDquDR64Y3OO6F/g7TffrnqguXq/xgDN9PZB14PtRHTicVwfefC0wcQs+hqH7CeNFDD38qvxmDN3JGtdjaCmqfrKT947V757gw08=&lt;/diagram&gt;&lt;/mxfile&gt;"><defs/><g><a xlink:href="10.0.0.1/24"><rect x="210" y="0" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 30px; margin-left: 211px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">cloud-router</div></div></div></foreignObject><text x="270" y="34" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">cloud-router</text></switch></g></a><path d="M 80 240 L 80 260 L 80 250 L 80 263.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 80 268.88 L 76.5 261.88 L 80 263.63 L 83.5 261.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><path d="M 80 180 Q 80 120 175 120 Q 270 120 270 66.37" fill="none" stroke="#82b366" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 270 61.12 L 273.5 68.12 L 270 66.37 L 266.5 68.12 Z" fill="#82b366" stroke="#82b366" stroke-miterlimit="10" pointer-events="all"/><rect x="20" y="180" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 210px; margin-left: 21px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">router-location-A</div></div></div></foreignObject><text x="80" y="214" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">router-location-A</text></switch></g><path d="M 480 240 L 480 260 L 480 250 L 480 263.63" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 480 268.88 L 476.5 261.88 L 480 263.63 L 483.5 261.88 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="420" y="180" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 210px; margin-left: 421px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">router-location-b</div></div></div></foreignObject><text x="480" y="214" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">router-location-b</text></switch></g><path d="M 270 185 Q 270 185 270 66.37" fill="none" stroke="#82b366" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 270 61.12 L 273.5 68.12 L 270 66.37 L 266.5 68.12 Z" fill="#82b366" stroke="#82b366" stroke-miterlimit="10" pointer-events="all"/><image x="247" y="184.5" width="45" height="50" xlink:href="https://app.diagrams.net/img/lib/active_directory/laptop_client.svg"/><path d="M 40 290 C 8 290 0 310 25.6 314 C 0 322.8 28.8 342 49.6 334 C 64 350 112 350 128 334 C 160 334 160 318 140 310 C 160 294 128 278 100 286 C 80 274 48 274 40 290 Z" fill="#ffffff" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 158px; height: 1px; padding-top: 310px; margin-left: 1px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">192.168.111.0/24</div></div></div></foreignObject><text x="80" y="314" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">192.168.111.0/24</text></switch></g><path d="M 440 290 C 408 290 400 310 425.6 314 C 400 322.8 428.8 342 449.6 334 C 464 350 512 350 528 334 C 560 334 560 318 540 310 C 560 294 528 278 500 286 C 480 274 448 274 440 290 Z" fill="#ffffff" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 158px; height: 1px; padding-top: 310px; margin-left: 401px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">192.168.155.0/24</div></div></div></foreignObject><text x="480" y="314" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">192.168.155.0/24</text></switch></g><path d="M 80 390 L 80 356.37" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 80 351.12 L 83.5 358.12 L 80 356.37 L 76.5 358.12 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="20" y="390" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 420px; margin-left: 21px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">host-a-0</div></div></div></foreignObject><text x="80" y="424" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">host-a-0</text></switch></g><path d="M 480 180 Q 480 120 375 120 Q 270 120 270 66.37" fill="none" stroke="#82b366" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 270 61.12 L 273.5 68.12 L 270 66.37 L 266.5 68.12 Z" fill="#82b366" stroke="#82b366" stroke-miterlimit="10" pointer-events="all"/><a xlink:href="10.0.0.2"><rect x="90" y="150" width="70" height="30" fill="none" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe flex-start; width: 68px; height: 1px; padding-top: 157px; margin-left: 92px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">10.0.0.2</div></div></div></foreignObject><text x="92" y="169" fill="#000000" font-family="Helvetica" font-size="12px">10.0.0.2</text></switch></g></a><a xlink:href="10.0.0.3"><rect x="490" y="150" width="70" height="30" fill="none" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe flex-start; width: 68px; height: 1px; padding-top: 157px; margin-left: 492px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">10.0.0.3</div></div></div></foreignObject><text x="492" y="169" fill="#000000" font-family="Helvetica" font-size="12px">10.0.0.3</text></switch></g></a><a xlink:href="10.0.0.4"><rect x="270" y="155" width="70" height="30" fill="none" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe flex-start; width: 68px; height: 1px; padding-top: 162px; margin-left: 272px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">10.0.0.4</div></div></div></foreignObject><text x="272" y="174" fill="#000000" font-family="Helvetica" font-size="12px">10.0.0.4</text></switch></g></a><a xlink:href="10.0.0.1/24"><rect x="280" y="60" width="90" height="30" fill="none" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe flex-start; width: 88px; height: 1px; padding-top: 67px; margin-left: 282px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">10.0.0.1/24</div></div></div></foreignObject><text x="282" y="79" fill="#000000" font-family="Helvetica" font-size="12px">10.0.0.1/24</text></switch></g></a><a xlink:href="192.168.111.0"><rect x="90" y="240" width="100" height="30" fill="none" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe flex-start; width: 98px; height: 1px; padding-top: 247px; margin-left: 92px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">192.168.111.1</div></div></div></foreignObject><text x="92" y="259" fill="#000000" font-family="Helvetica" font-size="12px">192.168.111.1</text></switch></g></a><a xlink:href="192.168.155.0/24"><rect x="490" y="240" width="120" height="30" fill="none" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe flex-start; width: 118px; height: 1px; padding-top: 247px; margin-left: 492px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">192.168.155.1</div></div></div></foreignObject><text x="492" y="259" fill="#000000" font-family="Helvetica" font-size="12px">192.168.155.1</text></switch></g></a><a xlink:href="192.168.111.2"><rect x="90" y="360" width="100" height="30" fill="none" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe flex-start; width: 98px; height: 1px; padding-top: 367px; margin-left: 92px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">192.168.111.2</div></div></div></foreignObject><text x="92" y="379" fill="#000000" font-family="Helvetica" font-size="12px">192.168.111.2</text></switch></g></a><path d="M 480 390 Q 480 390 480 356.37" fill="none" stroke="#000000" stroke-miterlimit="10" pointer-events="stroke"/><path d="M 480 351.12 L 483.5 358.12 L 480 356.37 L 476.5 358.12 Z" fill="#000000" stroke="#000000" stroke-miterlimit="10" pointer-events="all"/><rect x="420" y="390" width="120" height="60" fill="#ffffff" stroke="#000000" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe center; justify-content: unsafe center; width: 118px; height: 1px; padding-top: 420px; margin-left: 421px;"><div style="box-sizing: border-box; font-size: 0; text-align: center; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">host-b-0</div></div></div></foreignObject><text x="480" y="424" fill="#000000" font-family="Helvetica" font-size="12px" text-anchor="middle">host-b-0</text></switch></g><a xlink:href="192.168.155.0/24"><rect x="490" y="360" width="120" height="30" fill="none" stroke="none" pointer-events="all"/><g transform="translate(-0.5 -0.5)"><switch><foreignObject style="overflow: visible; text-align: left;" pointer-events="none" width="100%" height="100%" requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"><div xmlns="http://www.w3.org/1999/xhtml" style="display: flex; align-items: unsafe flex-start; justify-content: unsafe flex-start; width: 118px; height: 1px; padding-top: 367px; margin-left: 492px;"><div style="box-sizing: border-box; font-size: 0; text-align: left; "><div style="display: inline-block; font-size: 12px; font-family: Helvetica; color: #000000; line-height: 1.2; pointer-events: all; white-space: normal; word-wrap: normal; ">192.168.155.2</div></div></div></foreignObject><text x="492" y="379" fill="#000000" font-family="Helvetica" font-size="12px">192.168.155.2</text></switch></g></a></g><switch><g requiredFeatures="http://www.w3.org/TR/SVG11/feature#Extensibility"/><a transform="translate(0,-5)" xlink:href="https://www.diagrams.net/doc/faq/svg-export-text-problems" target="_blank"><text text-anchor="middle" font-size="10px" x="50%" y="100%">Viewer does not support full SVG 1.1</text></a></switch></svg>

Wireguard Site-to-Site VLAN

![](Wireguard Site-2-Site VPN.drawio.svg)

Source: https://twitter.com/lindworm/status/1451878726807998467

Preconditions

We assume here, that all nodes are running Linux. IP Forwarding will be enabled on all routing nodes. The config files should be named after the name of the VPN. Wireguard will name the VPN interface after the file.

Routing

Every node needs to know the route to the foreign nets. We can either add them manually or let our main router (the one that points to 0.0.0.0) know that the corresponding net is behind a VPN router.

So we need to point the route to the foreign net to the local address of the upstream VPN router.

  • On Fritz!Box: Heimnetz -> Netzwerk -> Netzwerkeinstellungen -> Statische Routingtabelle

  • Route example for reaching net B via router_location_A with local IP 192.168.111.100:

    $ ip route add 192.168.155.0/24 via 192.168.111.100

Troubleshooting

  • List all iptables rules

    $ iptables --list-rules
    $ iptables --list-rules --table nat
    $ iptables --flush
    $ iptables --flush --table nat
  • Turn on iptables logging

    $ iptables --append INPUT --jump LOG
    $ iptables --append OUTPUT --jump LOG
    $ iptables --append FORWARD --jump LOG
    $ iptables --append PREROUTING --table nat --jump LOG
  • Turn off iptables logging

    $ iptables --delete INPUT --jump LOG
    $ iptables --delete OUTPUT --jump LOG
    $ iptables --delete FORWARD --jump LOG
    $ iptables --delete PREROUTING --table nat --jump LOG

References

@suhlig
Copy link
Author

suhlig commented Jul 28, 2022

Thanks for the feedback. I'm not using this setup anymore; tailscale is far too easy ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment