Skip to content


Subversion checkout URL

You can clone with
Download ZIP
A TCP dns proxy which can get the RIGHT ip address
Python Shell Batchfile
Branch: master

Build Status

How to use this python script ?

  1. change your dns server to

    $ vi /etc/resolve.conf  
  2. restart the network

    $ sudo /etc/init.d/networking restart
  3. run the script

    $ sudo python -f tcpdns.json


usage: [-h] -f CONFIG_JSON [-d]


optional arguments:
  -h, --help      show this help message and exit
  -f CONFIG_JSON  Json config file
  -d              Print debug message

Configuration file

    "socket_timeout": 20,
    "host": "",
    "port": 53,
    "tcp_dns_server": ["",
    "udp_dns_server": [""],
    "enable_server_switch": true,
    "speed_test": true,
    "enable_lru_cache": true,
    "lru_cache_size"  : 100,
    "udp_mode"        : false,
    "daemon_process"  : false,
    "internal_dns_server": [""],
    "internal_domain": ["*intra*"],
    "private_host"    : {"*": ""}
  • enable_server_switch: switch dns servers if network is slow
  • speed_test : test dns server speed on startup
  • enable_lru_cache : use lru cache to store dns server responses
  • udp_mode : use udp dns procotol, default is tcp dns protocol
  • daemon_process : daemon process on *nix platform
  • internal_dns_server : internal dns server on internal network
  • internal_domain : internal domains which use internal dns server to get ip address
  • private_host : like /etc/hosts on *nix platform



python moudules


Super-quick installation

Linux system

  chmod +x ./

Windows system

Use tcpdns.exe in win directory.

Manual Installation

Ubuntu or Debian installation guide

  1. Use the following commands to install python modules

     sudo apt-get install libevent-dev
     sudo apt-get install python-pip
     sudo pip install gevent
     sudo pip install python-daemon
  2. Pull the submodule source code.

     cd Tcp-DNS-proxy
     git submodule update --init --recursive

Windows installation guide

In order to build gevent library you should install Visual Studio, although can run perfectly without python gevent. If you cannot run "C:\Python27\Scripts\pip.exe" in the CMD, you can try "C:\Python27\python.exe -m pip".

  1. Pull the submodule source code.

     cd Tcp-DNS-proxy
     git submodule update --init --recursive
  2. install python 2.7.9

  3. Install pip.exe

    Download from, execute the following commands:

  4. install greenlet

    C:\Python27\Scripts\pip.exe install greenlet
  5. install Microsoft Visual C++ Compiler for Python 2.7

    Download link

  6. Install python gevent

    C:\Python27\Scripts\pip.exe install gevent
  7. install pyinstaller

    C:\Python27\Scripts\pip.exe install pyinstaller
  8. execute toexe.bat


This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see

Something went wrong with that request. Please try again.