DNS resolution through a proxy

21,551

Solution 1

How can I make wget or even git use the proxy instead of a direct DNS query?

Set the proxy environment variable and it will do this straight up:

export http_proxy='http://proxy.contoso.com:3128/'
wget http://www.example.net/

Solution 2

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 the hostname to request. The modern web (HTTP/1.1) depends on a Host header always being present in a request, allowing one web server to serve multiple sites identified by their hostname.

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.

Resource - https://askubuntu.com/questions/447877/how-to-resolve-the-dns-locally-when-there-is-a-proxy-configured

Share:
21,551

Related videos on Youtube

nowox
Author by

nowox

Software and Electronic Engineer specialized in MotionControl applications.

Updated on September 18, 2022

Comments

  • nowox
    nowox over 1 year

    I am behind a very capricious proxy (squid) and it seems only http requests made with a particular user-agent are allowed.

    When fetching google.com from Google Chrome, I can see a HTTP GET on WireSharc. However, wget tries to resolve the DNS first through the default DNS servers which never answer.

    How can I make wget or even git use the proxy instead of a direct DNS query?

    • roaima
      roaima about 8 years
      If you're seeing that DNS requests are never answered, why do you think it's the fault of the proxy? Please edit your question to clarify.
    • nowox
      nowox about 8 years
      @roaima I never said it is the proxy's fault. I said wget is not doing the name resolution through the proxy.
    • roaima
      roaima about 8 years
      Please could you clarify the relevance of "it seems only http requests made with a particular user-agent are allowed" to the DNS lookup issue you're describing. I don't see the connection. Thanks.
    • Adrien
      Adrien almost 8 years
      if wget is still doing a DNS lookup for the target site (not the proxy) then it's not set to use a proxy. You could resolve the lookup problem with a hosts file entry, but that will just push the problem to the next stage, if it doesn't make a proper proxy request to the proxy, it will be rejected then.
  • nowox
    nowox about 8 years
    I already did it. From chrome I get a HTTP REQUEST and from wget I still get a TCP request to the DNS. So Chrome is just asking the proxy and wget tries to resolve the DNS first.
  • nowox
    nowox about 8 years
    So how is it possible that Chrome does not make a query to the DNS itself?
  • roaima
    roaima about 8 years
    @nowox I don't get any DNS lookup from wget in this configuration. What platform (OS) are you using?