Skip to content

Instantly share code, notes, and snippets.

@pschichtel
Last active January 11, 2021 18:53
Show Gist options
  • Save pschichtel/5cb8dc0fab064b82f89c6745ea23779a to your computer and use it in GitHub Desktop.
Save pschichtel/5cb8dc0fab064b82f89c6745ea23779a to your computer and use it in GitHub Desktop.
Batch script to enable IP forwarding on Windows. I use this to (ab)use Windows PCs as a Gateway into a site-to-site VPN.

Steps to setup external site

  1. Run setup_ip_forwarding.bat script to enable IP forwarding on Windows.
  2. Configure Windows firewall to accept traffic from all remote networks.
  3. Install wireguard and setup connection to central wireguard server with all remote networks as part of AllowedIPs and a unique IP within the wireguard network.
  4. Setup fritzbox to a custom local IP address range (e.g. 192.168.110.0/24) that is unique in all sites.
  5. Setup a static DHCP lease or a static IP for the local wireguard system.
  6. Setup static routes in fritzbox for each remote network using the local wireguard system's IP as the gateway/nexthop.
  7. For central wireguard server setup route for the network address range of the new external site.
:: Based on: https://michlstechblog.info/blog/windows-howto-enable-ip-routing/
reg add HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters /v IPEnableRouter /D 1 /f
sc config RemoteAccess start= auto
sc start RemoteAccess
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment