A small DNS server to enable local .dev domain resolution.
A small DNS server to enable local .dev domain resolution.
DevDNSd is a small DNS server which add a resolver to the system only for single TLD (by default, .dev). This way you can access your local application by typing every kind of url, i.e. locallapp.dev.
Of course, DevDNSd is inspired by pow, but it only provides DNS features, delegating the setup of a web-server to the user.
Install the gem:
gem install devdnsd
Install the service:
devdnsd install
You're done!
Just type devdnsd help and you'll see all available options.
By defaults, DevDNSd uses a configuration file in ~/.devdnsd_config, but you can change the path using the --config switch.
The file is a plain Ruby file with a single config object that supports the following directives.
foreground: If run the application in foreground.address: The IP to bind, 0.0.0.0 by default.port: The port to bind, 7771 by default.pid_file: The PID file to use.tld: The TLD to handle.log_file: The default log file. Not used if run in foreground.log_level: The default log level. Valid values are from 0 to 5 where 0 means "all messages".add_rule: Add a rule to the server. See section Rules below.DevDNSd has a nice rules system for matching name.
You can add rules by calling config.add_rule(...) into the configuration file.
The first argument of the function is the name you want to match. You can use regular expressions and this is highly recommended if you want to pass a block to the method (see below).
The second argument should be the IP associated to the name. If the first argument is a regexp with groups, you can use the standard Ruby String#gsub substitution syntax for the reply.
You can also use false to reject matching for this nameserver. In this case the next nameserver for the system will be used. You can skip this argument if you pass a block to the function.
If you return nil from the block, then you'll be responsible to set the response via the transaction variable.
The third argument can optionally be the record type for the resolv. By default is :A.
This argument is ignored if you pass the block, as it assumes that the second argument is the record type.
If you pass a block to the method, its return code will be taken as the result of the resolving. So if you return false then the resolving will be rejected. The block takes three arguments, match, type and transaction. If you used regular expression for the first argument, then match will contain all the match information for the name.
For some examples of rules, see the config/devdnsd_config.sample file into the repository.
DevDNSd as a local resolver is tightly coupled with the OSX name resolution system, so it is only available for MacOSX.
You can, anyway, run the software as DNS server.
Copyright (C) 2013 and above Shogun (shogun_panda@me.com).
Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.