mokeyish / smartdns-rs

A cross platform local DNS server (Dnsmasq like) written in rust to obtain the fastest website IP for the best Internet experience, supports DoT, DoQ, DoH, DoH3.
GNU General Public License v3.0
568 stars 39 forks source link
dns dns-over-h3 dns-over-https dns-over-quic dns-over-tls dns-server dnsmasq doh dot linux macos pi-hole rust smartdns smartdns-rs trust-dns trustdns windows

SmartDNS-rs

Test GitHub release (latest by date including pre-releases) homebrew version OS

Docs β€’ Discord

English | δΈ­ζ–‡

SmartDNS-rs πŸ‹ is a local DNS server imspired by C SmartDNS to accepts DNS query requests from local clients, obtains DNS query results from multiple upstream DNS servers, and returns the fastest access results to clients. Avoiding DNS pollution and improving network access speed, supports high-performance ad filtering.

Features

Note: The C version of smartdns is very functional, but because it only supports Linux, while MacOS and Windows can only be supported through Docker or WSL. Therefore, I want to develop a rust version of SmartDNS that supports compiling to Windows, MacOS, Linux and Android Termux environment to run, and is compatible with its configuration.


It is still under development, please do not use it in production environment, welcome to try and provide feedback.

Please refer to TODO for the function coverage

Installing

Nightly builds can be found here.

Configuration

The following is the simplest example configuration

# Listen on local port 53
bind 127.0.0.1:53  

# Configure bootstrap-dns, if not configured, call the system_conf, 
# it is recommended to configure, so that it will be encrypted.
server https://1.1.1.1/dns-query  -bootstrap-dns -exclude-default-group
server https://8.8.8.8/dns-query  -bootstrap-dns -exclude-default-group

# Configure default upstream server
server https://cloudflare-dns.com/dns-query
server https://dns.quad9.net/dns-query
server https://dns.google/dns-query

# Configure the Office(Home) upstream server
server 192.168.1.1 -exclude-default-group -group office

# Domain names ending with ofc are forwarded to the office group for resolution
nameserver /ofc/office

# Set static IP for domain name
address /test.example.com/1.2.3.5

# Block Domains (Ad Blocking)
address /ads.example.com/#

# The following features are not yet supported in the [C SmartDNS](https://github.com/pymumu/smartdns) and are only applicable to SmartDNS-rs.
# Configure DoH3
server-h3 1.1.1.1

# Configure DoQ
server-quic unfiltered.adguard-dns.com

For more advanced configurations, please refer to here , and refer to TODO for the function coverage.

Building

Assuming you have installed Rust, then you can open the terminal and execute these commands:

git clone https://github.com/mokeyish/smartdns-rs.git
cd smartdns-rs

# install https://github.com/casey/just
cargo install just

# build
just build --release

# print help
./target/release/smartdns --help

# run
sudo ./target/release/smartdns run -c ./etc/smartdns/smartdns.conf

For cross-compilation, it is recommended to use cross (requires Docker).

Acknowledgments !!!

This software wouldn't have been possible without:

License

This software contains codes from https://github.com/hickory-dns/hickory-dns, which is licensed under either of

And other codes is licensed under

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the GPL-3.0 license, shall be licensed as above, without any additional terms or conditions.