I'm looking for a method to restore properly my internet connection after VPN has been disconnected.
So i created this batch file in order to check my internet connection and try to repare and restore it with this command :
CMD /C %SystemRoot%\system32\msdt.exe Skip TRUE -path %Windir%\diagnostics\system\networking -ep NetworkDiagnosticsPNI The Problem seems that can't solve the issue internet connection after disconnecting from the VPN ???
So my question is there any command or even powershell command that can restore my internet connection ?
The Complete Batch code : Check_Internet_Connection.bat
@echo off Title Checking Internet Connection & Mode 70,4 & color 0B ::------------------------------------------------------------------------------------- REM First We Check The Status Of The Internet Connection Call :Check_Connection ::------------------------------------------------------------------------------------- :Main Title Your Extrenal IP Address Mode 50,4 & Color 0A for /f "tokens=2 delims=: " %%A in ( 'nslookup myip.opendns.com. resolver1.opendns.com 2^>NUL^|find "Address:" ^| findstr /v "208.67.222.222" ' ) Do ( If "%%A" NEQ "127.0.0.1" ( set "ExtIP=%%A" ) else ( Color 0C & echo( echo No internet connection ! ) ) echo( If defined ExtIP ( echo You are connected to the internet ! echo Your External IP is : %ExtIP% ) Pause>nul & Exit ::------------------------------------------------------------------------------------- :Check_Connection Title Checking Internet Connection ... SetLocal EnableDelayedExpansion Mode 50,3 & Color 0B echo( echo( Please Wait... Checking Internet Connection ... Timeout /T 1 /NoBreak>nul Ping -n 1 -w 1000>nul cls echo( if [!errorlevel!] EQU [1] ( Color 0C & set "internet=Not Connected To Internet" echo( Connection Status : !Internet! CMD /C %SystemRoot%\system32\msdt.exe ^ Skip TRUE -path %Windir%\diagnostics\system\networking -ep NetworkDiagnosticsPNI Timeout /T 1 /NoBreak>nul & Goto Check_Connection ) else ( Color 0A & set "internet=Connected To Internet" echo( Connection Status : !Internet! Timeout /T 1 /NoBreak>nul & Goto Main ) EndLocal ::------------------------------------------------------------------------------------- 42 Answers
See why what your VPN is doing that it does not restore your network settings. This does not normally happen to me or customers I deal with.
Try running TCP/IP and DNS Reset:
3Open cmd.exe with Run as Administrator
(1) netsh int ip reset c:\resetlog.txt
(2) ipconfig /flushdns
(3) restart the computer and test.
The network interface - Wi-Fi or wired - has two layers: physical and logical. Physical is whatever you can touch, everything else is logical.
The IP addressing configured for the NIC creates a logical interface that allows the system to communicate with the external world. Adding a VPN creates a separate logical interface, the tunnel between your system and the VPN provider. When the VPN disconnects, the OS has to switch from one logical interface to another, and Windows (or the driver) doesn't always handle such sudden changes gracefully.
Two things you could test when it's in failing state:
- Give commands
ipconfig /releaseandipconfig /renewto force new settings - Give command
netsh interface ip set address "Wi-Fi" dhcp. You can find the correct interface name with commandnetsh interface ip show config.
If either of these options work, you can just add it to your script.
To simplify troubleshooting I'd ping an IP address instead, for example Google's DNS 8.8.8.8. If you run the script and the ping works but browsing fails, you already know you have an IP and the gateway works, so something's failing in DNS. If ping to DNS name fails there are multiple possible points of failure.