{"id":4377,"date":"2024-08-17T14:28:38","date_gmt":"2024-08-17T18:28:38","guid":{"rendered":"https:\/\/dft.wiki\/?p=4377"},"modified":"2026-06-08T10:28:07","modified_gmt":"2026-06-08T14:28:07","slug":"enforcing-all-traffic-through-tor-network","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=4377","title":{"rendered":"Enforcing All Traffic Through Tor Network"},"content":{"rendered":"<p>Eventually, there is a need to access the Internet with an extra layer of privacy. What would one do?<\/p>\n<ul>\n<li>For a quick search about a sensitive subject without letting Google add it to your history, use the Tor Browser.<\/li>\n<li>For safely deploying malware and untrusted code, use Whonix to set up isolated networks.<\/li>\n<li>For those threatened by governments or fearing retaliation who need an anonymous way to communicate, use Tails OS.<\/li>\n<li>For accessing the Internet from a connection that may filter or log traffic, use a VPN or route all traffic through Tor (essentially a free VPN).<\/li>\n<\/ul>\n<p>Confirm your current public IP with the following commands. The first is an HTTP (TCP) request, the second checks whether your IP is a Tor exit node, and the third is a DNS (UDP) resolution request:<\/p>\n<pre>curl ip.me\r\ncurl -s https:\/\/check.torproject.org\/api\/ip | jq -r '.IsTor'\r\ndig +short myip.opendns.com @resolver1.opendns.com<\/pre>\n<p><strong>Note:<\/strong> The first command reveals your real public IP, the second returns true or false depending on whether your IP is a Tor exit node, and the third returns your public IP via a UDP DNS query.<\/p>\n<hr \/>\n<p><strong>INSTALLING TOR TUNNEL<\/strong><\/p>\n<p><strong>TorTunnel<\/strong> is a shell script that tunnels TCP and DNS traffic through the Tor network [<a href=\"https:\/\/github.com\/davift\/TorTunnel\">Link<\/a>]. It does not provide access to the dark web (.onion addresses), and does not support ICMP or UDP.<\/p>\n<p>This script routes all system traffic through Tor and was designed and tested on Ubuntu 24.04 LTS, removing the need to configure SOCKS per application or use <code>proxychains<\/code>.<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt upgrade -y\r\ngit clone https:\/\/github.com\/davift\/TorTunnel.git\r\ncd TorTunnel\r\nsudo .\/tortunnel.sh<\/pre>\n<p>It must be run with <code>sudo<\/code>:<\/p>\n<pre>Usage: tortunnel [--backup] [--install|--start] [--restore|--stop] [--refresh] [interface]\r\n\r\nRequired:\r\n --backup             backup the original system's configuration before installation\r\n --install, --start   make changes to the system's configuration and start tunneling\r\n --restore, --stop    restore the backup with original system's configuration\r\n --refresh            request Tor to acquire a new connection\r\n\r\nOptional:\r\n interface            defines what LAN interface to accept traffic on (requires --start)<\/pre>\n<p>The TorTunnel arguments:<\/p>\n<ul>\n<li><strong>&#8211;backup<\/strong>\n<ul>\n<li>Back up the original configuration before making any changes.<\/li>\n<\/ul>\n<\/li>\n<li><strong>&#8211;start<\/strong>\n<ul>\n<li>Start tunneling all traffic through Tor.<\/li>\n<\/ul>\n<\/li>\n<li><strong>&#8211;stop<\/strong>\n<ul>\n<li>Stop tunneling traffic and restore the previous configuration.<\/li>\n<\/ul>\n<\/li>\n<li><strong>&#8211;refresh<\/strong>\n<ul>\n<li>Restart the Tor service and establish new circuits.<\/li>\n<\/ul>\n<\/li>\n<li><strong>interface (e.g. eth0)<\/strong>\n<ul>\n<li>Optionally, tunnel traffic from a specific network interface, including inbound requests.<\/li>\n<li>With this option, all other hosts on a LAN can have their traffic transparently routed through Tor.<\/li>\n<li>Consider also installing a DHCP service to automatically configure client network interfaces on that segment.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Why use TorTunnel?<\/strong><\/p>\n<p>During penetration testing, it is often useful to appear as though you are coming from many different locations around the world, making traffic harder to track or block.<\/p>\n<p>TorTunnel can be installed in a system container (LXC) and works with scripts and automation without any modifications.<\/p>\n<hr \/>\n<p><strong>STARTING AND TESTING<\/strong><\/p>\n<pre>sudo .\/tortunnel.sh --backup\r\nsudo .\/tortunnel.sh --start<\/pre>\n<p>On a desktop environment, verify your connection using <strong>BrowserLeaks<\/strong> [<a href=\"https:\/\/browserleaks.com\/ip\">Link<\/a>] and <strong>DNS Leak Test<\/strong> [<a href=\"https:\/\/dnsleaktest.com\/\">Link<\/a>].<\/p>\n<p>From a terminal, repeat the HTTP and DNS tests:<\/p>\n<pre>curl ip.me\r\ncurl -s https:\/\/check.torproject.org\/api\/ip | jq -r '.IsTor'\r\ndig +short myip.opendns.com @resolver1.opendns.com<\/pre>\n<p><strong>Note:<\/strong> The first command will return the apparent IP, not your real one. The second will confirm you are using the Tor network. The third may return no output, since Tor does not route UDP traffic.<\/p>\n<hr \/>\n<p><strong>BONUS<\/strong><\/p>\n<p>Cloudflare offers a way to resolve DNS through the Tor network [<a href=\"https:\/\/developers.cloudflare.com\/1.1.1.1\/other-ways-to-use-1.1.1.1\/dns-over-tor\/\">Link<\/a>]. It creates a local SOCKS proxy that sends DNS requests over HTTPS (TCP) via Tor. Worth checking out!<\/p>\n<hr \/>\n<p><strong>READ MORE<\/strong><\/p>\n<p>Learn how to Set Up a Tor Node [<a href=\"https:\/\/dft.wiki\/?p=2354\">Link<\/a>].<\/p>\n<p>Read about Tor Snowflake Against Internet Censorship [<a href=\"https:\/\/dft.wiki\/?p=2346\">Link<\/a>].<\/p>\n<p>Deploy Whonix Gateway on Proxmox [<a href=\"https:\/\/dft.wiki\/?p=3350\">Link<\/a>].<\/p>\n<p>Set up your own OpenVPN Server [<a href=\"https:\/\/dft.wiki\/?p=348\">Link<\/a>].<\/p>\n<p>Create a bridge with WireGuard VPN Client and Server [<a href=\"https:\/\/dft.wiki\/?p=1380\">Link<\/a>].<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Eventually, there is a need to access the Internet with an extra layer of privacy. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-4377","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/4377","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4377"}],"version-history":[{"count":7,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/4377\/revisions"}],"predecessor-version":[{"id":5620,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/4377\/revisions\/5620"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4377"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4377"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4377"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}