DNS Proxy/Relay Implementation
DNS proxy or relay is used to forward DNS request and reply packets between the DNS client and DNS server.
In the network where DNS proxy or DNS relay is used, the DNS client sends DNS request packets to the DNS proxy or relay. The DNS proxy or relay forwards request packets to the DNS server and sends reply packets to the DNS client, and domain resolution is realized.
After DNS proxy or relay is enabled, if the IP address of the DNS server changes, you only need to change the configuration on the DNS proxy or relay. In this way, the network management is simplified.
Difference of Function Implementation Between the DNS Proxy and the DNS Relay
DNS relay is similar to DNS proxy. The difference is whether they search for DNS entries saved in the local domain name resolution table, including the static domain name resolution table and the local domain name cache after receiving DNS query messages from DNS clients.
The DNS proxy searches for DNS entries saved in the local domain name cache after receiving DNS query messages from DNS clients. If requested DNS entries are not saved in the cache, DNS query messages are forwarded to the DNS server.
The DNS relay does not searches for DNS entries saved in the local domain name cache after receiving DNS query messages from DNS clients. It forwards the messages directly to the DNS server for resolution. On one hand, it can save the cost for the cache on the DNS relay. On the other hand, it guarantees the real-time requirements for that the DNS client obtains resolution results. (If the domain names and IP addresses on the DNS server changes and the cache on the DNS proxy is not updated in time, the resolution result obtained by the DNS Client is incorrect.)
DNS Proxy Implementation
The application environments and implementation of DNS relay and DNS proxy are similar. Taking DNS Proxy as an example, Figure 4-2 shows the implementation of DNS Proxy and DNS Relay.
- The DNS client sends a request packet to the DNS proxy. The DNS proxy IP address is the destination address of the request packet.
- After receiving the request packet, the DNS proxy searches for DNS entries saved in the local domain name resolution tables.
- If mapping information exists, the DNS proxy sends a reply packet carrying the resolution result to the DNS client.
- If no mapping information exists, the DNS proxy sends the request packet to the DNS server for resolution.
- After receiving the reply packet from the DNS server, the DNS proxy records the resolution result and forwards the reply packet to the DNS client.
Only when the IP address of the DNS server and the route to the DNS server exist on the DNS proxy, the DNS proxy sends domain name resolution requests to the DNS server. Otherwise, the DNS proxy neither sends any domain name resolution request to the DNS server nor replies any request from the DNS client.