This project aims to implement a DNS library in rustlang based on, and only on, DNS-related RFCs. A DNS Client and a DNS resolver can be built using this library.
Implementation in progress.
As this library is build it in rustlang, is mandatory to have Rust installed.
First to clone the repository:
git clone https://github.com/niclabs/dns-rust.git
Then to use the library there are three options:
-
Installing the library with
cargo install
. This option let us run the library with the commanddns_rust ...
, Install the library with the following command:cargo install --path <PATH>
With the library installed it can be run it with
dns_rust
followed by any necessary option.dns_rust [options]
-
Using the library through
cargo
with cargocargo run
, accompanied by any neccessary option.cargo run [options]
-
Using the library's code in your new project.
Fisrt you need to add the dependency to your Cargo.toml file:[dependencies] dns_rust = { path = <PATH> }
Then to use the Library in your Rust code Import the library at the beginning of your Rust file.
use std::net::IpAddr; use dns_rust::async_resolver::AsyncResolver; use dns_rust::async_resolver::config::ResolverConfig; async fn resolver()-> Vec<IpAddr> { let config = ResolverConfig::default(); let domain_name = "example.com"; let transport_protocol = "TCP"; let mut resolver = AsyncResolver::new(config); let ip_addresses = resolver.lookup_ip(domain_name, transport_protocol).await.unwrap(); ip_addresses }
Here it can be specified whether to run a client or a resolver :
Argument | Description |
---|---|
client |
Execute a client that connects to the server and sends requests. |
resolver |
Runs a DNS resolver |
-
For the client there is three arguments:
Argument Description <SERVER>
DNS server ip <DOMAIN_NAME>
Host name to query for IP [OPTIONS]
EDNS0 options -
Six options:
Option Description --qtype <QTYPE>
Query type [default: A] --qclass <QCLASS>
Query class [default: IN] --norecursive
Disables the use of recursion when specified --payload <PAYLOAD>
Maximum payload for EDNS [default: 512] --noedns
Disables the use of EDNS when specified --protocol <PROTOCOL>
Transport protocol, options: "UDP", "TCP", "TLS" [default: UDP] --tsig <TSIG>
TSIG arguments key, algorithm, fudge, time_signed, key_name, mac_request -
And four EDNS0 options
EDNS0 option Description +nsid
NSID option code +padding
PADDING option code +ede
EDE option code +zoneversion
ZONEVERSION option code
-
For the resolver there are two arguments:
Argument Description <DOMAIN_NAME>
Host name to query [NAMESERVER]...
Recursive servers -
And three options:
Option Description --qtype <QTYPE>
Query type [default: A] --qclass <QCLASS>
Query class [default: IN] --protocol <PROTOCOL>
Protocol [default: UDP]
Additionally, the client and resolver have the command -h
or --help
to print the description of the structure and its usage.
dns_rust client "1.1.1.1" "example.com"
or
cargo run client "1.1.1.1" "example.com"
dns_rust client "1.1.1.1" "example.com" "+nsid"
dns_rust client "74.82.42.42" "example.com" "+nsid" "+padding"
dns_rust client --noedns "1.1.1.1" "example.com"
dns_rust client --qtype "MX" "1.1.1.1" "example.com"
dns_rust client --qtype "MX" --qclass "CH" "1.1.1.1" "example.com"
dns_rust resolver "example.com"
or
cargo run resolver "example.com"
dns_rust resolver "example.com" "1.1.1.1" "8.8.8.8"
dns_rust resolver --protocol "TCP" "example.com" "1.1.1.1" "8.8.8.8"
dns_rust resolver --protocol "TCP" --qtype "MX" "example.com"
- 1034 - Domain names, concepts and facilities.
- 1035 - Domain names, implementation and specification.
- 1123 - Requirements for Internet Hosts -- Application and Support.
- 2181 - Clarifications to the DNS Specification.
- Negative Caching
- 2308 - Negative Caching of DNS Queries (DNS NCACHE)
- 9520 - Negative Caching of DNS Resolution Failures
- 3596 - DNS Extensions to Support IP Version 6
- 3597 - Handling of Unknown DNS Resource Record (RR) Types
- Edns0
- 6891 - Extension Mechanisms for DNS (EDNS(0))
- 5001 - DNS Name Server Identifier (NSID) Option
- 7830 - The EDNS(0) Padding Option
- 8914 - Extended DNS Errors
- 9660 - The DNS Zone Version (ZONEVERSION) Option
- Tsig
- 8945 - Secret Key Transaction Authentication for DNS (TSIG)
- DNSSEC is not supported at the moment, but it will be eventually.
Javiera Alegria.
- github user @Javi801
- email [email protected]