How to resolve the DNS locally when there is a proxy configured?

31,009

This isn't possible when you use an HTTP proxy because:

  • The server you connect to is that of the proxy, not of the ultimate destination.
  • You send the full URL (including hostname) of your request to the proxy. The proxy then does the request on your behalf.

Therefore, it must be the proxy that does the DNS lookup.

It isn't possible to do the DNS lookup locally, and send only the IP address to the proxy server. Firstly, there is no mechanism to specify that the proxy should try a particular IP address for a particular host. You could change the URL from, say, http://example.com/mypage to http://33.33.33.33/mypage, but then the proxy server won't know which hostname to request, an importanta part of the modern web (HTTP/1.1 and later), which depends on a Host header always being present in a request, removing the restriction that all hostnames be served from different IP addresses.

Your best bet would be to configure the proxy server to use the DNS resolver of your choice. This would only be possible if you use a local proxy server that you control.

Note: When you use a SOCKS proxy or another lower-level tunnelling method, you can use a local DNS server. Just not with an HTTP proxy.

Share:
31,009

Related videos on Youtube

ThiagoCMC
Author by

ThiagoCMC

Updated on September 18, 2022

Comments

  • ThiagoCMC
    ThiagoCMC almost 2 years

    If I configure the proxy, under Settings -> Network -> Proxy, and then try to access "http://google.com", the name resolution (IP of google.com) will happen there, at the proxy server but...

    How can I change this behavior?

    I mean, I need to resolve the DNS locally at my Desktop, BEFORE hitting the proxy.

    But why?

    This way, I'll configure "ignore-hosts with lots of subnets (IPv4 / IPv6), that don't need the proxy to reach them", then, Ubuntu first needs to:

    1- Resolve the DNS locally (i.e. not via proxy too);

    2- Try to match the locally discovered website IP with "ignore-hosts" settings;

    Is it possible?

    Tks! Thiago

  • ThiagoCMC
    ThiagoCMC about 10 years
    Thank you! Nice explanation... But, I'm still thinking that I it would be better to resolve the DNS locally, just to match the ignore-hosts settings. Like this: 1- If the site IP matches ignore-hosts settings, then, don't go via proxy. Otherwise: 2- if the site IP doesn't match ignore-hosts, then, go via proxy as usual. - Can I achieve this? Nevertheless, I'll take a look of socks... Tks again!
  • thomasrutter
    thomasrutter about 10 years
    I guess it's possible that you could do an additional DNS request locally in addition to the DNS request the HTTP proxy server does, I don't know if you have that option "out of the box" though.
  • artenaki
    artenaki over 2 years
    thomasrutter, you are wrong. It is possible. As for PAC: DNS in this case is still resolved through HTTP proxy, but also locally.
  • David
    David over 2 years
    if you want the interned user to see your message you need to do as I have done here and prefaced the name with the at symbol.