title: Can I temporarily override DNS resolution within a .NET application?
body: <p>I have some wrapper code that runs a set of NUnit tests that scan live websites for certain response codes.</p>
  
  <p>I'd like to run these tests against a different server. When running manually, I can do this by editing the /etc/hosts file in Windows\System32\drivers and temporarily setting www.mysite.com to 10.0.0.whatever</p>
  
  <p>Is there any way I can do the same within a .NET console application  - temporarily override a DNS record or somehow intercept the resolution and return a different IP address?</p>
  
  <p>EDIT: This is for testing multiple servers in a web farm. I have three live servers, all of which THINK they are www.example.com. Because the servers use HTTP host headers, I can't just run a test against server1, then server2, then server3, because an HTTP request to  <a href="http://server1/" rel="nofollow noreferrer">http://server1/</a> will NOT return the same thing as a request to <a href="http://www.example.com/" rel="nofollow noreferrer">http://www.example.com/</a> that's resolved to server1...</p>