title: How to do the DNS-Request in a local Proxy Server?
body: <p>I'm writing a local Proxy server. It already works for the majority of the requests. But sometimes I have Problems when I want to resolve the Host-name. Here is what I do:</p>
  
  <p>When the header of the request is received, I filter the first line out. Then I take the Request-URL (which is between the two spaces) out of that line and store it into an Uri object. After that I extract the hostname with: <code>string host= uri.host;</code>
  At least I do the DNS-call: <code>IPAddress[] ips = Dns.GetHostAddresses(host)[0];</code> 
  (How do I know here, which IP of the array I should take. Whats the difference between those IP's)</p>
  
  <p>Like I said, for the majority of the Requests that works fine. But there are some adresses, that cannot be resolved. Here an example: When I want to open <strong>www.gmx.net</strong>, I first get the HTML-File ( this works fine ). After that, the Browser reloads a couple of Web-Objects like pics, javascript and so on. Those Object of course have some URL. And one of those URLs, that cannot be resolved is:   <strong>ipv4-cout.gmx.net</strong> .
  The attempt to resolve this URL results in the warning: <strong>The stated Host is unknown</strong>.</p>
  
  <p>Another thing I need to know is: How to handle Alias-Host-names? For example: When I enter the hostname gmx.de into the Browser, it automaticaly resolves it into www.gmx.net. I know, there are Recource Reccords on a DNS-Server with type CNAME, but I dont know how to implement this.</p>