This guide assumes a Windows PC, but Linux users should be able to figure it out. Start by copying your hosts file to C:\ Now open powershell as administrator and go to C:\
$Domains = Get-Content -Path hosts
And this:
$Domains | ForEach-Object{
$Lookup =nslookup $_ 2>&1 | Select -First 1
$Filter = ($Lookup -split 'domain')[0]
$Result = $_ + " " + $Filter
$Result | Out-File -FilePath HostsMOD -append
}
Copy/Paste these two blocks of code...it is going to take hours if not days if not weeks; depends on how many hosts file entries you have. When it is done what you have to do now is modify HostsMOD with notepad ++.
Go to the search menu, Ctrl + F, and open the Mark tab. Check Bookmark line (if there is no Mark tab update to the current version).
Enter your search term Non-existent and click Mark All Do the same for the term Unspecified error.
All lines containing the search terms are bookmarked. Now go to the menu Search → Bookmark → Remove Bookmarked lines Save. Rename file to "Hosts" and place in your respective OS directory: system32\drivers\etc.
Done.