Coder Social home page Coder Social logo

jwfh / aws-vpc-dns-address Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amitsaha/aws-vpc-dns-address

0.0 0.0 0.0 11 KB

Get AWS DNS Server address within a VPC instance

License: Apache License 2.0

Shell 24.52% Go 55.00% PowerShell 20.48%

aws-vpc-dns-address's Introduction

Get AWS DNS Server address within a VPC instance

The problem

AWS Route 53 private hosted zones enable you to have private DNS names which only resolve from your VPC. This is great when working from EC2 instances since everything is setup and ready to go. This however becomes a problem when using docker containers on a systemd system. On such a system, systemd-resolved sits in between your host applications and name resolution. The entry in /etc/resolv.conf is basically, 127.0.0.53 which doesn't mean much when you want name resolution from a docker container which defaults to 8.8.8.8 for name resolution. Hence, we need a way to set AWS VPC DNS server as an additional DNS server for the docker daemon.

Hence, this small utility. This is basically a golang version of the comment by Dusan Bajic here. Having a Golang binary means, I can use this on Linux and Windows. Running the program will print the DNS server, which you can then use for example to set the DNS server in docker to be able to resolve private DNS names.

Download

Download a binary from the releases tab, extract the zip.

Usage

This program will likely be run at instance start up either in user data or as part of your configuration management. Hence, I recommend using a HTTP client to download the zip, extract it and put it somewhere in your system.

On Windows using PowerShell:

> Invoke-WebRequest https://github.com/amitsaha/aws-vpc-dns-address/releases/download/v0.1/aws-vpc-dns-address-0.1-windows-amd64.zip -OutFile aws-vpc-dns-address.zip
> Expand-Archive .\aws-vpc-dns-address.zip
> cd .\aws-vpc-dns-address\

> mv .\aws-vpc-dns-address-0.1-windows-amd64 .\aws-vpc-dns-address-0.1-windows-amd64.exe
> .\aws-vpc-dns-address-0.1-windows-amd64.exe
172.34.0.2

On Linux, using wget:

$ wget https://github.com/amitsaha/aws-vpc-dns-address/releases/download/v0.1/aws-vpc-dns-address-0.1-linux-amd64.zip
$ unzip ..
$ mv aws-vpc-dns-address-0.1-linux-amd64 /usr/local/bin
$ sudo chmod +x /usr/local/bin/aws-vpc-dns-address-0.1-linux-amd64
$ aws-vpc-dns-address-0.1-linux-amd64
172.34.0.2

Then, you can use it, for example:

vpc_dns=$(aws-vpc-dns-address)
echo '{"dns":["'"$vpc_dns"'", "8.8.8.8"]}' > /etc/docker/daemon.json
cat /etc/docker/daemon.json
systemctl restart docker

License

See LICENSE

aws-vpc-dns-address's People

Contributors

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