HTTP Proxy DNS Resolution Mechanics: How IE Handles Lookups with Proxy Bypass Rules


1 views

When dealing with HTTP traffic through proxy servers in Internet Explorer, the DNS resolution process exhibits some non-intuitive behaviors that every network-aware developer should understand. Here's the complete technical breakdown:

// Pseudo-code of IE's DNS resolution logic
function resolveAndRoute(url, proxyConfig) {
    const bypassList = proxyConfig.bypassRules;
    
    // Step 1: Perform DNS lookup regardless of proxy settings
    const destinationIP = performDnsLookup(url.hostname);
    
    // Step 2: Check proxy bypass rules after DNS resolution
    if (isInBypassList(url.hostname, destinationIP, bypassList)) {
        return directConnection(destinationIP);
    } else {
        return proxyConnection(proxyConfig.address);
    }
}

Contrary to what many developers assume, IE performs DNS lookups before consulting proxy bypass rules. This implementation detail has several implications:

  • DNS queries may leak for domains that ultimately get proxied
  • Bypass rules can use both hostnames and IP addresses
  • The client's DNS cache affects proxy routing decisions

Consider this PowerShell snippet to test proxy behavior:

$proxyBypass = @("contoso.com","192.168.*","10.*")
$testUrls = @("http://contoso.com", "http://internal-server", "http://google.com")

foreach ($url in $testUrls) {
    $dnsResult = [System.Net.Dns]::GetHostAddresses($url)
    $willProxy = $proxyBypass -notcontains $url.Host -and 
                 $proxyBypass -notmatch $dnsResult.IPAddressToString
    
    Write-Host "$url - Will proxy: $willProxy (Resolved to $($dnsResult.IPAddressToString))"
}

Using Wireshark or Microsoft Message Analyzer, you'll observe this sequence:

  1. DNS query for the target hostname (UDP port 53)
  2. TCP SYN to proxy server (if not bypassed)
  3. HTTP CONNECT request (for HTTPS targets)

When writing network-aware applications that must respect system proxy settings:

// C# example using WebProxy class
var proxy = WebRequest.DefaultWebProxy;
var bypass = proxy.IsBypassed(new Uri("http://internal-resource"));

if (bypass) {
    // Handle direct connection logic
    var client = new WebClient();
} else {
    // Configure proxy settings
    var client = new WebClient {
        Proxy = new WebProxy("corporate-proxy:8080")
    };
}

Always test with both FQDN and IP address formats in your bypass list to ensure consistent behavior across different network configurations.


How DNS Lookups Work with HTTP Proxy in Internet Explorer

When examining proxy behavior in IE, DNS resolution follows this sequence:

  1. Client initiates HTTP request
  2. System performs DNS lookup using configured resolver
  3. Proxy bypass list evaluation occurs post-resolution
  4. Request routes either directly or through proxy

The critical detail often missed: DNS resolution happens before proxy evaluation in IE's architecture. This differs from some modern browsers that implement proxy-aware DNS.

// Pseudo-code of IE's internal handling
function handleHttpRequest(url) {
    // Step 1: Perform DNS regardless of proxy settings
    ipAddress = performDnsLookup(url.hostname);
    
    // Step 2: Check proxy exceptions list
    if (isInProxyBypassList(url.hostname)) {
        return sendDirect(ipAddress);
    } else {
        return sendViaProxy(ipAddress);
    }
}

This architecture creates two important consequences:

  • Performance: Extra DNS lookup when proxy will ultimately be used
  • Security: DNS leaks occur before proxy evaluation

To verify this behavior:

nslookup example.com
netstat -ano | findstr ESTABLISHED

Compare results with and without proxy settings. You'll observe DNS queries occurring in both scenarios.

Typical PAC file implementation would include:

function FindProxyForURL(url, host) {
    // Bypass proxy for local addresses
    if (isPlainHostName(host) ||
        shExpMatch(host, "*.local")) {
        return "DIRECT";
    }
    
    // Route all others through proxy
    return "PROXY proxy.example.com:8080";
}

Contemporary approaches often implement:

  • Proxy-first DNS resolution
  • DNS-over-HTTPS integration
  • Connection pooling optimizations

The legacy IE behavior remains important for enterprise applications and backward compatibility scenarios.