Skip to content

Instantly share code, notes, and snippets.

@AtomicMaya
Last active June 24, 2021 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AtomicMaya/7a5d34c114bcecb27eef4a8486843388 to your computer and use it in GitHub Desktop.
Save AtomicMaya/7a5d34c114bcecb27eef4a8486843388 to your computer and use it in GitHub Desktop.
@echo off
REM DOCKER / WSL2 / HYPER-V Systems with sometimes blocked ports you don't understand why are blocked.
REM TL;DR It's WinNAT that's reserving them, here's how you still let WinNAT do it's job but get a usable chunk of your ports back.
REM THIS COMMAND LISTS ALL RESERVED PORTRANGES FOR TCP (can be changed to ipv6 and/or udp)
netsh interface ipv4 show excludedportrange protocol=tcp
REM THIS COMMAND SETS IT TO BE DYNAMIC AND THE FUCK OUT OF ANY DEVELOPER'S WAY
REM (Run in Admin powershell)
netsh int ipv4 set dynamic tcp start=49152 num=16384
REM Fucking hell microsoft...
REM Here for original fix https://github.com/docker/for-win/issues/3171#issuecomment-554587817
REM Restart the WinNAT service (Run in Admin powershell)
net stop winnat
net start winnat
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment