Giter Club home page Giter Club logo

dns-override's Introduction

DNS Override

Used to override DNS settings for a single process (and its decendants) using the glibc resolv

See my post about it:
http://blog.backslasher.net/dns-override.html

How it works

The library monkeypatches fopen and looks for calls for /etc/resolv.conf, and returns a file pointer to a memory stream containing a customized version of resolv.conf.
The new resolv.conf is built by the script based on the current resolv.conf and passed as the RESOLV_CONF environment variable.
We then use LD_PRELOAD to insert our library (and version of fopen) before the "real" one.
It then execs the wanted binary.
Since both LD_PRELOAD and RESOLV_CONF are environment variables, they'll pass on to subprocesses too.

Common Usgae

  1. Build dns-override.so if needed (make dns-override.so)
  2. determine replacement DNS servers
  3. run desired file like so: ./dns-override.sh -s SERVER BINARY)
    Multiple servers can be specified, see script

Advanced usage

Run LD_PRELOAD=./dns-override.so:$LD_PRELOAD RESOLV_CONF=<new resolv conf contents> <binary>.
Do note that I'm only covering fopen which isn't used by all programs. For instance, python will be fooled but perl will not.

Testing

bats, perl and python are required.

  1. Run make test

dns-override's People

Contributors

backslasher avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  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.