'How a dns proxy works? (smart dns)

I am trying to build a new DNS, which will act as a proxy for certain domain names and uses a public DNS as upstream.

My understanding of DNS:

  1. Client asks DNS (x.x.x.x) about example.com
  2. DNS will look up inside its zones (or parent and root) and find example.com can be found at i.i.i.i
  3. DNS will send i.i.i.i to the client.

Now, client asks the ip address of restricted.test and DNS server knows it is a restricted website, so instead of giving the direct ip to the website, it gives it's own proxy address p.p.p.p to the client.

Please correct me if I'm wrong till now, but when the client tries to connect to p.p.p.p how the proxy server knows which website the client wants to go in?

I really want to know how these work under the hood

Thanks in advance.



Solution 1:[1]

This mechanism you are asking about is the Proxy Auto-Configuration (PAC) file.

Read more about it here :

https://developer.mozilla.org/en-US/docs/Web/HTTP/Proxy_servers_and_tunneling/Proxy_Auto-Configuration_PAC_file

And here :

https://www.websense.com/content/support/library/web/v76/pac_file_best_practices/PAC_explained.aspx

Essentially in corporate networks, a PAC file is pushed out to every computer, and browser settings are also configured to enable the PAC file. But it can also be done manually. Just check your browser proxy settings to see the location of the PAC file it is pointed to.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 madacoda