I recently moved to a new PC and there's something wrong with the network configuration. The hardware seems OK but every few hours Windows reports that there is no Internet connection. I haven't spent much time troubleshooting but it looks like the PC loses its IP lease and does not renew it, but that's mostly just a guess at this stage.
The Windows 7 Troubleshooter reports:
The Network Diagnostics Framework has completed the diagnosis phase of operation. The following repair option was offered:
Helper Class Name: AddressAcquisition
Root Cause: "Local Area Connection" doesn't have a valid IP configuration
Root Cause Guid: {245a9d66-ae9c-4518-a5b4-655752b0a5bd}
Repair option: Investigate router or broadband modem issues
If you're connected to a hotspot or domain network, contact the network administrator. Otherwise:
1. Unplug or turn off the device.
2. After all the lights on the device are off, wait at least 10 seconds.
3. Turn the device on or plug it back into the power outlet.
To restart a router or modem that has a built-in battery, press and quickly release the Reset button.
RepairGuid: {9513cc1c-4a26-4cb8-bf89-0a82129bd105}
Seconds required for repair: 63
Security context required for repair: 0
Interface: Local Area Connection ({419b3c06-e283-4a99-adaa-b66439dd064d})
Running the Troubleshooter does fix the issue. It appears that this tool resets the network adapter which forces a new IP to be allocated to the interface.
I've never had this type of issue with Ethernet on Windows before, although I have experienced unstable 802.11 connections on certain laptops.
I've also updated the Intel NIC driver to see if this would help - it didn't.
Others do seem to have this issue also. Most people use the workaround of assigning a static IP to the adapter - this isn't an option for me in this environment.
Anyway, I need to remote into this PC so I can't have it sitting there with a non-working network connection!
So to get around this problem, I wrote a script in Powershell which I've scheduled in Task Scheduler to run every 10 minutes. The script will check if the network connection has Internet connectivity and, if not, will reset the network adapter. So the longest I'll have to wait to get on to the PC will be 10 minutes.
Here it is:
# Set up event log source# redirect stderr to null since there's no simple way to check if the source already exists(
new-eventlog -logname Application -Source "Reset Network Adapter")
2> $null$pingResponse = Get-WmiObject -Class Win32_PingStatus -Filter "Address='www.google.com.au'" -ComputerName . | Select-Object -Property Address,ResponseTime,StatusCodeif (
$pingResponse.ResponseTime
-eq $null) {
Write-Host Network connection down. Resetting adapter. write-eventlog Application -source "Reset Network Adapter" -eventid 1 -message "Network connection down. Resetting adapter." # Assumes you have only one ethernet device in your PC. If you have more, use something like: '-and $_.Name like "*Intel*"' $adapter = Get-WmiObject -Class Win32_networkadapter | Where-Object {
$_.AdapterType
-eq "Ethernet 802.3" }
$adapter.disable()
$adapter.enable()
}
else {
Write-Host Network connection seems OK write-eventlog Application -source "Reset Network Adapter" -eventid 2 -message "Network connection seems OK"}
Hope that helps someone!
Scheduling the Task
This is quite simple but I recommend creating a new user on your system to run the task. For the above script they need to be in the Local Admin group in order to create the event log.
Add an action with:
command: powershell
and
arguments: -file path_to\reset-adapter.ps1
An Exercise for the Reader
You can trigger a Windows scheduled task based on an event. When the network fails there are a bunch of events that are generated by applications and the System. You could pick one that reliably represents this network issue and set up your scheduled task to only run when this event is detected. This is a nicer approach that polling every 10 minutes.
Some hints for finding appropriate events in the System Log:
- Source: Time-Service, DNS Client Events
Resources