# DS-Lite IPv6 Tunnel – Port Forwarding – NAT – WireGuard VPN

#   


[![image.png](https://bst.wkmimnl.de/uploads/images/gallery/2024-11/scaled-1680-/deNimage.png)](https://bst.wkmimnl.de/uploads/images/gallery/2024-11/deNimage.png)

NAT IPv6 Port Forward Cloud Server

Viele Internetnutzer haben eine **Dual Stack** Internetverbindung mit einer nicht eigenen **IPv4 und/oder IPv6** Adresse. Dabei hat man schnell das Problem wenn man auf seine eigenen Dienst zugreifen möchte, keine Verbindung zu Stande kommt. Die IPv4 und die IPv6 Verbindung wechselt eventuell oder die IPv4 ist eine NAT Adresse usw. Es gibt also viele Hürden wieso man nicht an seine Dienst immer dran kommt.

Im besten Fall sucht man sich also einen Punkt im Internet der gut erreichbar ist und der die Anfragen an deine Dienste weiterleitet. Hier in diesem Beispiel mieten wir uns einen Cloud Server mit einer eigenen IPv4 &amp; IPv6 Adresse. Somit sind die Dienste immer über beide Internet Protokolle erreichbar.

<div class="post-content" id="bkmrk--3" style="box-sizing: border-box; padding: 36px; color: rgb(68, 68, 68); font-family: Roboto, sans-serif; font-size: 18px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><figure class="wp-block-gallery has-nested-images columns-default wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex" style="margin: 0px; gap: var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) ); box-sizing: border-box; flex-wrap: wrap; align-items: normal; display: flex; --wp--style--unstable-gallery-gap: var( --wp--style--gallery-gap-default, var( --gallery-block--gutter-size, var( --wp--style--block-gap, 0.5em ) ) );">[![image.png](https://bst.wkmimnl.de/uploads/images/gallery/2024-11/scaled-1680-/HSyimage.png)](https://bst.wkmimnl.de/uploads/images/gallery/2024-11/HSyimage.png)

  
  
</figure></div>## Lösungsbeschreibung

Du brauchst folgendes

<div class="post-content" id="bkmrk-cloud-server%C2%A0-%3E-z.b." style="box-sizing: border-box; padding: 36px; color: rgb(68, 68, 68); font-family: Roboto, sans-serif; font-size: 18px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">- **Cloud Server** -&gt; z.B. Hetzner Cloud (kleinster Server) [HIER 20€ STARTGUTHABEN](https://hetzner.cloud/?ref=B7SA7EkDfqfL)
- **VPN Gateway** -&gt; z.B. pfSense // [Hardware Appliance](https://amzn.to/3nFKVbK)

</div>Es wird zwischen dem Cloud Server und deinem VPN Gateway ein Wireguard VPN Tunnel aufgebaut. Diese Verbindung kann über IPv4 oder IPv6 aufgebaut werden. Da diese Verbindung sowieso durch deine pfSense initiiert wird, ist es egal ob v4 oder v6.

Auf dem Cloud Server wird die unten stehen WireGuard Konfiguration genommen und somit auch die 4 Wunderregeln für das DNAT (Destination NAT).

```
[Interface]
Address = 10.0.0.2/24
ListenPort = 51820
PrivateKey = <YOUR-PRIVATE-KEY>
PostUp = iptables -A FORWARD -i eth0 -o wg0 -j ACCEPT
PostUp = iptables -A FORWARD -i wg0 -o eth0 -j ACCEPT
PostUp = iptables -t nat -A PREROUTING -i eth0 -p tcp -m multiport --dport 3000 -j DNAT --to 192.168.77.1
PostUp = iptables -t nat -A POSTROUTING -o wg0 -j MASQUERADE

PostDown = iptables -D FORWARD -i eth0 -o wg0 -j ACCEPT
PostDown = iptables -D FORWARD -i wg0 -o eth0 -j ACCEPT
PostDown = iptables -t nat -D PREROUTING -i eth0 -p tcp -m multiport --dport 3000 -j DNAT --to 192.168.77.1
PostDown = iptables -t nat -D POSTROUTING -o wg0 -j MASQUERADE

[Peer]
PublicKey = <YOUR-PUBLIC-KEY>
AllowedIPs = 192.168.77.0/24, 10.0.0.0/24
```

Mit dieser Konfiguration wird der Port 3000 eingehend auf dem Server mittels DNAT auf die Zieladresse 192.168.77.1 weitergeleitet. (**PREROUTING**)  
Mit dem **PORTROUTING** wird dem Daten-Paket die IP-Adresse des Wireguard Tunnel aufgezwungen.  
Die beiden **FORWARD** Regeln geben dem System die Freigabe Pakete zwischen beiden Interfaces zu verschieben.

Natürlich kann die besonders wichtige Regel „PREROUTING“ so angepasst werden das diese für euch passt. Man kann auch UDP Freigaben oder mehrere Ports gleichzeitig freigeben.

#  

# mit 

```
iptables -I DOCKER-USER -i eth0 ! -s 127.0.0.1 -p tcp --dport 81 -j DROP
```

Wird die Managementseite des Proxys von außen gesperrt.

Alle weitere Informationen natürlich wie immer im Video.

<div class="post-content" id="bkmrk-video-%C2%A0ansichten%3A%C2%A013" style="box-sizing: border-box; padding: 36px; color: rgb(68, 68, 68); font-family: Roboto, sans-serif; font-size: 18px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; white-space: normal; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;"><figure class="wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio" style="margin: 0px; box-sizing: border-box; overflow-wrap: break-word;"><div class="wp-block-embed__wrapper" style="box-sizing: border-box; position: relative; margin-bottom: 0px;">[Video](https://youtu.be/7QBh1YVoaj8 "Erläuterungsvideo")</div></figure><div class="post-views content-post post-3596 entry-meta load-static" style="box-sizing: border-box;"> <span class="post-views-label" style="box-sizing: border-box; margin-right: 0px !important; line-height: 1;">Ansichten: </span><span class="post-views-count" style="box-sizing: border-box; margin-bottom: 0px; margin-right: 0px !important; line-height: 1;">13.909</span></div></div>