{"id":23817999,"url":"https://github.com/lsongdev/dns2socks","last_synced_at":"2025-09-07T00:32:54.070Z","repository":{"id":68773697,"uuid":"209227697","full_name":"lsongdev/dns2socks","owner":"lsongdev","description":"Forward DNS requests to a DNS server via a SOCKS tunnel","archived":false,"fork":false,"pushed_at":"2019-09-18T08:51:59.000Z","size":34,"stargazers_count":13,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-31T10:05:21.278Z","etag":null,"topics":["dns2socks","socks-proxy"],"latest_commit_sha":null,"homepage":"https://sourceforge.net/projects/dns2socks/","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lsongdev.png","metadata":{"files":{"readme":"ReadMe.txt","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"song940","patreon":"song940","open_collective":"song940","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://git.io/fjRcB"}},"created_at":"2019-09-18T05:47:13.000Z","updated_at":"2024-07-21T20:50:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"bcd591bd-f913-4b31-98cd-e7f7d6abfe16","html_url":"https://github.com/lsongdev/dns2socks","commit_stats":null,"previous_names":["lsongdev/dns2socks"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fdns2socks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fdns2socks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fdns2socks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lsongdev%2Fdns2socks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lsongdev","download_url":"https://codeload.github.com/lsongdev/dns2socks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232158299,"owners_count":18480860,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns2socks","socks-proxy"],"created_at":"2025-01-02T05:49:18.037Z","updated_at":"2025-01-02T05:49:18.617Z","avatar_url":"https://github.com/lsongdev.png","language":"C","funding_links":["https://github.com/sponsors/song940","https://patreon.com/song940","https://opencollective.com/song940","https://git.io/fjRcB"],"categories":[],"sub_categories":[],"readme":"Description for DNS2SOCKS\r\n-------------------------\r\n\r\nDNS2SOCKS is a command line utility running to forward DNS requests to a\r\nDNS server via a SOCKS or HTTP tunnel.\r\n\r\nI know that this is no new idea, but let me explain why I've coded this:\r\nWindows supports using a SOCKS server for Internet connections, but it\r\nonly uses the SOCKS server for the content and not the DNS requests. I\r\nfound several articles in the Internet referring this issue. There seem\r\nto be tools that do exactly the same thing as DNS2SOCKS, but they either\r\nneed a scripting interpreter or are not available for downloading anymore.\r\n\r\nSo I've coded an own tool. It's very(!) simple and doesn't use any\r\nsophisticated technology.\r\n\r\nTo use it, just configure your OS to use the DNS server on the local\r\nIP address 127.0.0.1 (IPv4) and/or ::1 (IPv6). On Windows: open the\r\nproperties of your network adapter. For IPv4 open the properties of\r\n\"Internet Protocol Version 4 (TCP/IPv4)\", select \"Use the following DNS\r\nserver addresses\" and enter \"127.0.0.1\" for the \"Preferred DNS server\".\r\nFor IPv6 open the properties of \"Internet Protocol Version 6\r\n(TCP/IPv6)\", select \"Use the following DNS server addresses\" and enter\r\n\"::1\" for the \"Preferred DNS server\".\r\n\r\nAfter that run your SOCKS server (must support SOCKS protocol version 5,\r\nfor example Tor) or HTTP proxy and start DNS2SOCKS using the correct\r\ncommand line switches (see below). Now all DNS requests of your OS\r\n(triggered by any application) run through DNS2SOCKS and your SOCKS\r\nserver or HTTP proxy.\r\n\r\nYou can additionally configure Windows to use your SOCKS server for\r\nInternet connections (for the content, not DNS). To do this open the\r\n\"Internet Options\" of the control panel, select the tab \"Connections\" and\r\nclick on \"LAN settings\". Check \"Use a proxy server for your LAN...\" and\r\nclick on \"Advanced\". Enter your SOCKS server address and port in the field\r\n\"Socks\". Now Internet Explorer and other tools using these settings get\r\nweb pages via your SOCKS server. This works with most browsers. However,\r\nyou should rely on IPv4 for Tor here as (most?) Tor exit servers currently\r\ndon't support IPv6 (see below).\r\nThe settings are similar for using a HTTP proxy.\r\n\r\nThe command line call for DNS2SOCKS has the following format:\r\n\r\nDNS2SOCKS [/?] [/t] [/d] [/q] [l[a]:FilePath] [/u:User /p:Password]\r\n          [Socks5ServIP[:Port]] [DNSServIPorName[:Port]] [ListenIP[:Port]]\r\n\r\n/?            or any invalid parameter outputs the usage text\r\n/t            to use a HTTP proxy instead of a SOCKS server\r\n              (here: Socks5ServIP = HttpProxyIP, no support for /u and /p)\r\n/d            disables the cache\r\n/q            disables the text output to the console\r\n/l:FilePath   creates a new log file \"FilePath\"\r\n/la:FilePath  creates a new log file \"FilePath\" or appends to the file if\r\n              it already exists\r\n/u:User       user name if your SOCKS server uses user/password\r\n              authentication\r\n/p:Password   password if your SOCKS server uses user/password\r\n              authentication\r\n\r\nThe default values for the addresses and ports are (in case you don't\r\nspecify the command line arguments):\r\nDefault Socks5ServerIP:Port = 127.0.0.1:9050\r\nDefault DNSServerIPorName:Port = 213.73.91.35:53\r\nDefault ListenIP:Port = 127.0.0.1:53\r\n\r\nSo the SOCKS server runs locally on the TCP port 9050 (Tor's default port;\r\nattention: for Tor Browser Bundle you must change it to 9150). The used\r\nDNS server is 213.73.91.35 (dnscache.berlin.ccc.de). The DNS server must\r\nsupport TCP on port 53 as Tor doesn't support UDP via SOCKS. DNS2SOCKS\r\nlistens on the UDP port 53 of 127.0.0.1 (only locally) - change this to\r\n0.0.0.0 for listening on all available local IPv4 addresses.\r\n\r\nYou can launch DNS2SOCKS several times with different settings, for\r\nexample to listen on IPv6 addresses additionally. To specify an IPv6\r\naddress, use the typical format like 1234:5678::1234. To add the port\r\nnumber please embed the IP address in square brackets and add the port\r\nnumber separated by the colon, e.g. [::1]:1024\r\n\r\nHint: In the default configuration Tor only listens on 127.0.0.1 for\r\nincoming requests. You can change this in Tor's configuration file using\r\nthe following line\r\nSocksListenAddress 192.168.1.1\r\nIn this example it listens on 192.168.1.1\r\nCurrently Tor doesn't support IPv6 addresses for listening.\r\n\r\nPlease note that Tor/Vidalia will output warnings that your application\r\ndoesn't resolve host names via Tor. This is not true, but Tor can't know\r\nthis as Tor doesn't recognize the tunneled DNS requests. DNS2SOCKS\r\ndirectly uses the IP address of the DNS server while using SOCKS and also\r\nyour application will do this as it gets the IP address from DNS2SOCKS.\r\nTor expects getting the host names instead of IP addresses and thus\r\noutputs these warnings.\r\n\r\nHowever, instead of an IP address you can also specify the DNS server's\r\nname instead of its IP address, e.g.\r\nDNS2SOCKS 127.0.0.1 dnscache.berlin.ccc.de ::1\r\nSpecifying an IPv6 address for the DNS server is also supported by\r\nDNS2SOCKS, but it's not recommended to do this as your current Tor exit\r\nserver would need to support IPv6, which it typically doesn't. So it's\r\nbetter to specify the DNS server name as the exit server can choose IPv4\r\nor IPv6 automatically this way. Directly specifying an IPv4 address might\r\nbe a bit faster; currently all Tor exit servers should support this.\r\n\r\nAs DNS requests running through the SOCKS/HTTP tunnel are very slow, the\r\ncalling application might time out before it gets the answer - in this\r\ncase just try it again (press \"reload\" in the browser).\r\n\r\nThe output of DNS2SOCKS is very simple. On each new request it outputs\r\nthe requested name prefixed by the current number of entries in the\r\ncache (just an increasing number in case the cache is disabled) and a time\r\nstamp. DNS2SOCKS caches DNS requests, so the next time it can serve the\r\nanswer faster. The cache is a very simple list. There is no sophisticated\r\nhash algorithm or something like that for the cache and DNS2SOCKS doesn't\r\nreally interpret the DNS requests and answers - it just forwards them.\r\n\r\nDNS2SOCKS runs as long as you don't manually stop it.\r\nYou can also run several instances of DNS2SOCKS at the same time when\r\nusing different local ports or IPv4 and IPv6 at the same time, e.g. use a\r\nbatch file and Window's Start command to do this.\r\n\r\nIf you think that DNS2SOCKS is not the right tool for you, but you want\r\nto route all network traffic of a specific Windows application through a\r\nSOCKS tunnel, you might want to try my tool InjectSOCKS.\r\n\r\n\r\n\r\nNow about some technical details:\r\nDNS2SOCKS listens on the local UDP and TCP port you specify. In case it\r\ngets a request it first searches the cache for an identical request.\r\nIn case of a cache miss or expiration of the entry, the tool creates a new\r\nthread for resolving the request. The new thread opens a TCP connection to\r\nthe SOCKS server and forwards the DNS request. This time the DNS request\r\nalways runs on TCP as Tor currently doesn't support UDP via SOCKS. So the\r\nDNS server must support TCP. When the thread finally gets the answer, it\r\nforwards it via UDP or TCP to the requesting client and stores it in the\r\ncache. DNS2SOCKS supports user/password authentication (method 0x02) for\r\nSOCKS.\r\n\r\nI've tried to comment the source code as good as possible and you can\r\ncompile it using Visual C++ 2010 Express Edition (or any other edition).\r\nI've also tested it on Knoppix and Damn Small Linux and compiled it via\r\ngcc -pthread -Wall -O2 -o DNS2SOCKS DNS2SOCKS.c\r\nIt should also run on other *nix variants; maybe with tiny modifications.\r\n\r\nHave fun using this software!\r\n\r\nghostmaker\r\n\r\n\r\n\r\nLicense (3-clause BSD License)\r\n------------------------------\r\n\r\nCopyright (c) 2012, ghostmaker\r\nAll rights reserved.\r\n\r\nRedistribution and use in source and binary forms, with or without\r\nmodification, are permitted provided that the following conditions are\r\nmet:\r\n   * Redistributions of source code must retain the above copyright\r\n     notice, this list of conditions and the following disclaimer.\r\n   * Redistributions in binary form must reproduce the above copyright\r\n     notice, this list of conditions and the following disclaimer in the\r\n     documentation and/or other materials provided with the distribution.\r\n   * Neither the name of ghostmaker nor the names of its contributors may\r\n     be used to endorse or promote products derived from this software\r\n     without specific prior written permission.\r\n\r\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\r\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED\r\nTO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r\nPURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ghostmaker BE LIABLE FOR ANY\r\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\r\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\r\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER\r\nCAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\r\nLIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\r\nOUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\r\nSUCH DAMAGE.\r\n\r\n\r\n\r\nChanges of version 2.0 (released on 2015-06-28)\r\n-----------------------------------------------\r\n\r\n- Added command line parameter /t to use a HTTP proxy instead of a SOCKS5\r\n  server (HTTP CONNECT tunneling)\r\n- SHA256 for DNS2SOCKS.exe:\r\n  ba841370b0d79b776438eb22a9131e91250025b55db4200db8f66a060cf6047d\r\n\r\n\r\nChanges of version 1.9 (released on 2015-06-18)\r\n-----------------------------------------------\r\n\r\n- Added fallback to old IPv4 parsing via \"inet_addr\" in case \"getaddrinfo\"\r\n  fails (workaround for erroneous \"getaddrinfo\" implementation)\r\n- SHA256 for DNS2SOCKS.exe:\r\n  5612bf263136852c39d929691b63a103c166f78bbd606d7947ce1d813c28c560\r\n\r\n\r\nChanges of version 1.8 (released on 2015-01-01)\r\n-----------------------------------------------\r\n\r\n- Support for IPv6\r\n- Support for DNS server name instead of IP address\r\n- Added BSD license text to ReadMe.txt\r\n- Minor tweaks\r\n- SHA256 for DNS2SOCKS.exe:\r\n  d654659b031ede16224fa37f585c735112a689f46497afc3fca6ccd4cde70b93\r\n\r\n\r\nChanges of version 1.7 (released on 2013-11-14)\r\n-----------------------------------------------\r\n\r\n- Support for SOCKS5 user/password authentication (method 0x02)\r\n- SHA256 for DNS2SOCKS.exe:\r\n  63c0fd8f9dcd3f3546691892999d868ce74601778111dcf08cdfeb140818d28e\r\n\r\n\r\nChanges of version 1.6 (released on 2013-10-21)\r\n-----------------------------------------------\r\n\r\n- Cache function respects the \"time to live\" field of DNS answers\r\n- Command line parameter /d to disable the cache\r\n- SHA256 for DNS2SOCKS.exe:\r\n  45a20efacb8fed901299712ae2ee6147ac453d69c349b0766024cb5d3634a0b5\r\n\r\n\r\nChanges of version 1.5 (released on 2013-10-06)\r\n-----------------------------------------------\r\n\r\n- Removed several compiler warnings that appeared when compiling for\r\n  some platforms (tested on Knoppix V7.2.0 64 bit)\r\n- Additional output of system error text in case of system call failure\r\n- Added Windows application manifest \"supportedOS\" entry for Windows 8.1\r\n- Bugfix: Output of settings at startup was missing\r\n- SHA256 for DNS2SOCKS.exe:\r\n  8e987da2a57e5be942c21c76e28e185279a527ed67a468dab5757d38dc1e37ea\r\n\r\n\r\nChanges of version 1.4 (released on 2013-01-19)\r\n-----------------------------------------------\r\n\r\n- Command line parameter /l:filePath or /la:filePath to create a log file\r\n  for the output (/la for appending)\r\n- Output has a time stamp for each line\r\n- SHA256 for DNS2SOCKS.exe:\r\n  cae8aab900897b2c03bd8f3d415de91df596479bca2f83b107455ba68de28793\r\n\r\n\r\nChanges of version 1.3 (released on 2012-11-03)\r\n-----------------------------------------------\r\n\r\n- DNS requests/responses via TCP additionally to UDP (still always via\r\n  TCP for transportation via SOCKS)\r\n- UDP requests/responses can now have the maximum possible size for UDP\r\n- You can specify the local port number to use for UDP and TCP\r\n- You can specify the remote port number to use for contacting the DNS\r\n  server\r\n- You can compile the sources on Unix/Linux now and use it like on\r\n  Windows. You only need DNS2SOCKS.c and stdafx.h for that and compile\r\n  it with a command like\r\n  gcc -pthread -Wall -O2 -o DNS2SOCKS DNS2SOCKS.c\r\n  (tested on Damn Small Linux; use sudo to run it as otherwise it's\r\n  impossible to bind port 53; please be aware that the connect time-\r\n  out on Linux is typically several minutes while it is just some\r\n  seconds on Windows, so in case connecting to the SOCKS server doesn't\r\n  work, it takes very long until you see an error message)\r\n- On Windows DNS2SOCKS is no console application anymore, but it creates\r\n  its own new console window at start-up; this way you can start it with\r\n  the new /q option to suppress any output and it has no window in this\r\n  case - use the Task Manager to terminate it\r\n- SHA1 for DNS2SOCKS.exe: 596015cba187a9184c5b480b8666c0d4b37d9552\r\n\r\n\r\nChanges of version 1.2 (released on 2012-01-13)\r\n-----------------------------------------------\r\n\r\nYou can configure the listen address via the command line now. The default\r\nis 127.0.0.1 instead of 0.0.0.0 of version 1.1. This way the Windows\r\nfirewall doesn't show up.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsongdev%2Fdns2socks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flsongdev%2Fdns2socks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flsongdev%2Fdns2socks/lists"}