dns2tcp
dns2tcp is a set of tools to encapsulate TCP sessions inside DNS packets, creating a TCP-over-DNS tunnel. It allows tunneling traffic through firewalls that only permit DNS traffic.
Description
dns2tcp provides a server (dns2tcpd) and client (dns2tcpc) for tunneling TCP traffic over DNS protocols. This is useful for bypassing network restrictions where only DNS traffic is allowed through firewalls or NAT devices. The tool uses TXT records within a subdomain to carry the tunneled data, requiring a NS record pointing to the tunnel server.
Common use cases include accessing internal services from behind restrictive perimeters or exfiltrating data covertly. The client does not require root privileges, making it flexible for various environments. Configuration is done via rc files specifying domains, keys, resources, and ports.
The tunnel achieves better throughput than IP-over-DNS due to smaller packet sizes. Resources like SSH can be mapped to local ports on the client side for easy access.
How It Works
dns2tcp encapsulates TCP sessions within DNS TXT records queried to a specific subdomain. The server (dns2tcpd) listens on UDP/53 and responds to queries from authorized clients using a pre-shared key. Client (dns2tcpc) binds a local port and forwards traffic by encoding it into DNS queries sent to the server's domain. A NS record must point the subdomain to the server IP. Compression is optional, and resources are defined to map remote services to local ports.
Installation
sudo apt install dns2tcpFlags
Examples
cat >>.dns2tcpdrc <<END
listen = 0.0.0.0
port = 53
user=nobody
chroot = /root/dns2tcp
pid_file = /var/run/dns2tcp.pid
domain = dns2tcp.kali.org
key = secretkey
resources = ssh:127.0.0.1:22
ENDdns2tcpd -f .dns2tcpdrccat >>.dns2tcprc <<END
resource = ssh
local_port = 2139
key = secretkey
ENDdns2tcpc -f .dns2tcprcssh root@localhost -p 2139 -D 8090dns2tcpc -z dns2tcp.kali.org -r ssh -k secretkey -l 2139dns2tcpd -f .dns2tcpdrc -F -d 1