Skip to content

Simple proxy DNS server for local development

Notifications You must be signed in to change notification settings

casimcdaniels/olodum

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OLODUM olodum logo

/etc/hosts made easy.

Tired of editing your /etc/hosts ? Olodum acts as a local filtering DNS proxy :

  • every DNS request containing a domain name that is configured to be catched will returned the IP you specify,
  • every other request will be forwarded to your real DNS servers

Why olodum? Because I'm a fan of Michael. Just look at the video clip "They don't care about us"

Requirements

NodeJS >= v0.4 (http://nodejs.org/)

Modules installation

Olodum should be used and installed globally

[sudo] npm install olodum -g

Supported env

  • linux (ubuntu,debian)
  • macosx
  • that's all

windows port in the TODO list

Usage

sudo olodum [host1] [host2] [-t target]

where :

  • host1, host2 are the filters, default to blank (=> every DNS requests are catched). Can be a part of a hostname
  • target is the IP address to respond with when a domain name matches host, default to 127.0.0.1
  • if target is not an IP then target is first resolved to an IP address (before olodum is started)

sudo is needed to bind to local port 53 (DNS server)

You should be able to surf as usual, except for the filtered domain name(s). When you are finished, just type Ctrl + C to exit and revert to the previous and original DNS configuration of your box.

#Use cases ##/etc/hosts replacement When developping proxy, web or cache servers, inserting lines in /etc/host can quickly be cumbersome and boring. You've got plenty of commented lines, don't know if your configuration is up to date regarding one of the domain names your are testing, you're doing host and dig to find real IPs to put in this file, ... Just use Olodum!

Want to serve a new www.google.com site? Just start your local webserver and use:

sudo olodum www.google.com -t 127.0.0.1

Want to map www.gooooogle.com on www.google.com to see if goog uses vhosts? Just use:

sudo olodum www.gooooogle.com -t www.google.com

##wildcard domain names If you've got wildcard domain names to point to one IP, you need to enter each line in your /etc/hosts With olodum, just use the fixed portion of the domain name in the filter:

sudo olodum google

In this example, every DNS request containing google will be answered with 127.0.0.1 (default IP). It's equivalent to these lines in /etc/hosts:

127.0.0.1 www.google.com
127.0.0.1 mail.google.com
[.... snip ....]
127.0.0.1 plus.google.com
127.0.0.1 maps.google.com

CNAME

When you're setting up a proxy, a cache, a CDN or even better, a frontend optimizer for your live servers and you want to test if their configuration is ok, instead of using one of the provider IP, use the future used CNAME as the target for olodum:

sudo olodum www.fasterize.com -t www.fasterize.com.fasterized.org

and you're ready to go and test your fasterized website!

##blackhole webperf test Imagine a world where facebook, google+ or twitter widgets were 100% uptime ... Huh?! So, test your website with olodum activated for one of these domains and see the result on your website loading time!

sudo olodum twitter

##temporary AdBlocker Start a web server on 127.0.0.1:80

sudo node -e "require('http').createServer(function(req,res) {res.end('')}).listen(80)"

Start olodum

sudo olodum crappyadserver.net

Hahaha! bye-bye crappy AdServers!

(Starting the web server will be included in future version of olodum, list of adServers too.)

Tests

sudo npm test

Tests are not complete, must work on it and use Mocha.

Caveats

Not compliant with AAAA (IPV6) records.

Inner working

##linux

  1. read and backup /etc/resolv.conf
  2. write a new /etc/resolv.conf with 127.0.0.1 as the DNS server
  3. start the DNS server
  4. serve DNS responses based on filter or forward the request to the first DNS server detected in /etc/resolv.conf

##macosx

  1. read and backup /etc/resolv.conf
  2. change the network configuration with 127.0.0.1 as the DNS server
  3. start the DNS server
  4. serve DNS responses based on filter or forward the request to the first DNS server detected in /etc/resolv.conf

TODO

  • windows port
  • AdBlocker & blakchole management based on blacklists
  • regex on host
  • tests

Thanks

This module is based on these dns library for nodejs: https://github.com/iriscouch/dnsd and https://github.com/jsjohnst/ndns (no more maintained, this fork is more up-to-date : https://github.com/atrniv/ndns).

Licence

Do what you want. Have fun with JS.

About

Simple proxy DNS server for local development

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 91.7%
  • Shell 8.3%