Skip to content

Accurio/DnsProxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dns Proxy

简体中文

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.

Features

  • 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.json file.
  • 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.

Configuration

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.

Example

{
  "DnsProxy": {
    "Forwarders": {
      "Any": ["223.5.5.5", "223.6.6.6"],
      "AAAA": ["2400:3200::1", "2400:3200:baba::1"]
    }
  }
}

In this example:

  • All AAAA record queries will be forwarded to 2400:3200::1 or 2400:3200:baba::1 (Alibaba Cloud DNS).
  • All other types of queries will be forwarded to 223.5.5.5 or 223.6.6.6 (Alibaba Cloud DNS).

How to Run

Run as a Console Application

Execute DnsProxy.exe directly. Closing the console window will stop the service.

Run as a Windows 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.

Install Service

sc.exe create DnsProxy binPath= "<%ProgramFiles%\DnsProxy.exe>" start= auto

Please replace <%ProgramFiles%\DnsProxy.exe> with the actual absolute path to DnsProxy.exe.

Start Service

sc.exe start DnsProxy

Stop Service

sc.exe stop DnsProxy

Delete Service

sc.exe delete DnsProxy

Build

You can use dotnet to build the project.

dotnet publish

This command will generate a self-contained DnsProxy.exe executable and the appsettings.json configuration file in the bin\Release\net10.0\publish directory.

About

A simple DNS proxy for IPv4/IPv6 dual-stack network

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages