This is a simple DNS proxy service that can forward DNS queries to different upstream DNS servers based on the DNS query type (e.g., A records and AAAA records).
This project can solve the problem of needing to use different DNS servers for address resolution of different IP protocols in a mixed ISP network environment with both IPv4 and IPv6 stacks. For example, you can use the DNS server provided by the IPv4 ISP to resolve A records, while using the DNS server of the IPv6 ISP to resolve AAAA records.
- Forward by Record Type: Forwards requests to specified DNS servers based on the query's record type (
A,AAAA, etc.). - Simple Configuration: Easily configure DNS servers via the
appsettings.jsonfile. - Self-Contained Deployment: Can be published as a single executable file without needing the .NET runtime installed.
- Windows Service: Can run continuously in the background as a Windows service.
Configure the DNS servers by modifying the appsettings.json file.
The configuration is located under the DnsProxy:Forwarders node, which is a dictionary where the key is the DNS record type (case-insensitive) and the value is a list of one or more DNS server IP addresses. The Any key is used to configure a default DNS server, which will be used when no server is configured for a specific query type.
{
"DnsProxy": {
"Forwarders": {
"Any": ["223.5.5.5", "223.6.6.6"],
"AAAA": ["2400:3200::1", "2400:3200:baba::1"]
}
}
}In this example:
- All
AAAArecord queries will be forwarded to2400:3200::1or2400:3200:baba::1(Alibaba Cloud DNS). - All other types of queries will be forwarded to
223.5.5.5or223.6.6.6(Alibaba Cloud DNS).
Execute DnsProxy.exe directly. Closing the console window will stop the service.
You can use the sc.exe command to install and manage the service. Run Command Prompt or PowerShell as an administrator and execute the following commands.
sc.exe create DnsProxy binPath= "<%ProgramFiles%\DnsProxy.exe>" start= autoPlease replace <%ProgramFiles%\DnsProxy.exe> with the actual absolute path to DnsProxy.exe.
sc.exe start DnsProxysc.exe stop DnsProxysc.exe delete DnsProxyYou can use dotnet to build the project.
dotnet publishThis command will generate a self-contained DnsProxy.exe executable and the appsettings.json configuration file in the bin\Release\net10.0\publish directory.