Coder Social home page Coder Social logo

awsresolver's Introduction

awsresolver

Very basic DNS server that resolves AWS's EC2 internal FQDNs (ex: ip-192-0-2-1.us-west-2.compute.internal) by extracting the IP out of the hostname.

Includes an optional subcommand that sets up macOS to automatically direct all "*.internal" queries to this daemon.

Requirements

  • Go 1.13 or later to build.

NOTE: Only macOS is currently supported.

Installation

  1. Run: brew install brandt/personal/awsresolver
  2. Run: sudo awsresolver setup (installs /etc/resolver/internal)
  3. Run: brew services start awsresolver

Confirm it's working

This hooks into macOS's resolver. That means things like ping and ssh will do what you expect, but dig will not.

To confirm it's working, run: ping ip-192-0-2-1.us-west-2.compute.internal

If awsresolver is correctly setup, you will see ping attempt to reach 192.0.2.1:

# SUCCESS                                     vvvvvvvvv
PING ip-192-0-2-1.us-west-2.compute.internal (192.0.2.1): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1

How it works

This tool listens for A record requests ending in .internal, extracts the IP from the requested name, and returns it as a response. It binds to UDP and TCP 127.0.0.1:1053.

Mac OS X has a cool feature that allows you to configure different resolvers by domain. (See: man 5 resolver) When you run sudo awsresolver setup, it writes a config file to /etc/resolver/internal that steers *.internal requests to 127.0.0.1:1053.

Note that the resolver(5) config only applies to DNS resolution performed through the built-in OS facilities. So ping, ssh, and Chrome will be routed to this resolver, but by default dig will not.

To query with dig, point it directly at the resolver like so: dig @127.0.0.1 -p 1053 ip-192-0-2-1.us-west-2.compute.internal

Building

To build from source, simply run these commands from inside this repo:

go mod vendor # optional
make

The compiled binary is here: bin/awsresolver

Uninstalling

To uninstall:

  1. Run: sudo rm -f /etc/resolver/internal
  2. Run: brew uninstall awsresolver

Author

  • J. Brandt Buckley

awsresolver's People

Contributors

brandt avatar

Stargazers

 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.