Skip to content
Menu

Internet Works but Nothing Loads - Reset the Network Stack

Resets Winsock and the TCP/IP stack, flushes DNS and by default renews DHCP leases. Refuses machines with static IPs unless allowed. Dry run until approved; a restart finishes it.

Internet works but nothing loads - reset the network stack is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Internet works but nothing loads - reset the network stack. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1, administrator rights
Changes thingsChanges what it runs on

What It Does

The script resets Winsock, resets the TCP/IP stack, and flushes the DNS cache. With ResetProxy it also clears the machine-wide WinHTTP proxy, and with RenewDhcp (on by default) it renews the lease of every connected DHCP adapter, last of all.

The TCP/IP reset can clear static IP settings, so the script refuses to run while a connected adapter has a static IPv4 address. With AllowStaticAdapters it saves each static adapter's address, prefix, gateway and DNS servers first, sets them again after the reset and checks them.

The machine loses its network briefly. A remote session or an RMM agent can disconnect while the leases renew; the script keeps running and finishes locally. The Winsock reset only completes after a restart, which the script never does itself. It does not touch firewall rules, VPN profiles, adapter drivers or the per-user proxy.

Before You Run It

  • Expect to lose your remote session for a moment. Have another way back in if this is the only machine at the site.
  • Plan the restart. The reset is not finished until the machine restarts.
  • Do not use AllowStaticAdapters on a server you cannot reach by console, even though it restores the settings.
  • Try clear-dns-cache first when only names fail to resolve. It is far less disruptive.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: High. It is a dry run unless you set both DryRun=false and Approve=reset-network-stack, and it stops before making more than 25 changes in one run unless you raise MaxChanges. Run it once as a dry run and read the list first.
  • What it changes: Resets Winsock and the TCP/IP stack; flushes DNS; renews DHCP leases; restores static IP settings when allowed; optionally clears the WinHTTP proxy.
  • Restart: A restart is needed to finish. It never restarts the machine itself, and the answer says so.
  • Typical run: Under 2 minutes.
  • Example answer: "Reset Winsock and TCP/IP, flushed DNS, renewed 1 DHCP lease; reboot needed to finish"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • RenewDhcp: true to renew the lease of each connected DHCP adapter, last. Default true.
  • ResetProxy: true to also clear the WinHTTP machine proxy. Default false.
  • AllowStaticAdapters: The script refuses to run while a connected adapter has a static IPv4 address, because the TCP/IP reset can wipe it and leave a server off the network after the restart. true runs anyway: it saves each static adapter's address, prefix, gateway and DNS servers first, sets them again after the reset and checks them. Default false.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

reset-network-stack.ps1 · 918 lines · 47.5 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.