Code Monkey home page Code Monkey logo

dns_tunnel's Introduction

A simple DNS tunnel based on WebSocket

I write this to fix DNS pollution in China:

DNS query <--> client <--> WebSocket <--> server <--> DNS server

Deploy on your server

Install websockets:

pip3 install websockets

Run it:

./server.py -p 9999

Now it's listening on localhost 9999, next to config nginx, add a location for it:

location /shining_tunnel {
    proxy_pass http://127.0.0.1:9999;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
}

Please use HTTPS, not only for security, but also to avoid possible breakage caused by ISP's performance tuning on HTTP.

Deploy on Heroku

Clone this branch, then push:

git push heroku master

Run client

Very simple:

./client.py -c wss://dns-tunnel.herokuapp.com -p 12345

Yes, you could try the demo app above, but it will be online 18 hous per day. Now test:

$ dig +short twitter.com @127.0.0.1 -p 12345
199.59.150.7
199.59.149.230
199.59.150.39
199.59.149.198

Running inside docker containers

Building a docker image

$ docker build -t dnstunnel:latest .

Running as a server

$ docker run -d --env mode=server --name=dserver -P dnstunnel:latest -b 0.0.0.0

Please follow instructions above to set up nginx as an SSL termination. To make fixed port mappings either on server or client, replace -P/--publish-all with -p/--publish option. Otherwise you need to run docker port to figure out which port is actually listen on the host.

Running as a client

$ docker run -d --name=dclient -P dnstunnel:latest -c wss://test.com/shining_tunnel -d

Get port mappings

Running docker port to find out the port mappings.

# server side
$ docker port dserver
5353/tcp -> 0.0.0.0:32770
5353/udp -> 0.0.0.0:32770

# client side
$ docker port dclient
5353/tcp -> 0.0.0.0:32775
5353/udp -> 0.0.0.0:32775

You should be able to send DNS requests to client port.

Huge thanks to the WebSockets project!

dns_tunnel's People

Contributors

radaiming avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.