Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WattsInABox/d70c0f2ee2aa7400320dfcbb5a009e3f to your computer and use it in GitHub Desktop.
Save WattsInABox/d70c0f2ee2aa7400320dfcbb5a009e3f to your computer and use it in GitHub Desktop.

AWS internal ip's

EMR has components running on internal ip's such as ip-172-23-53-101.ec2.internal. To resolve to the implied public/vpn IP's, setup dnsmasq

Setup dnsmasq on Mac

(You'll need to do something different on windows. Linux should have another installer.)

$ brew install dnsmasq

Configure dnsmasq

$ cp /usr/local/Cellar/dnsmasq/2.80/.bottle/etc/dnsmasq.conf /usr/local/etc/dnsmasq.conf
$ vim /usr/local/etc/dnsmasq.conf # add following to the end of the file

# AWS IPs see - http://stackoverflow.com/questions/28204678/dns-service-to-dynamically-resolve-subdomain-to-a-custom-ip-address
address=/ec2.internal/127.0.0.1
synth-domain=ec2.internal,0.0.0.0,255.255.255.255,ip-

Start dnsmasq

$ sudo brew services start dnsmasq

Configure OSX with the new dnsserver

If networksetup is a utility on your version you can do something like the following:

$ networksetup -setdnsserver Wi-Fi 127.0.0.1 8.8.8.8 # or whatever dns server you had to begin with

Else, you'll need to modify your network settings in System Preferences -> Network. For EACH connection, you'll have to:

  1. Click on the connection in question (LAN, Wi-FI, USB, etc.) to select it
  2. Click on the "Advanced..." button
  3. Click on the DNS tab
  4. If the DNS servers are greyed out, copy them into a text editor (i.e. if they're the default DNS servers as given by your ISP or whatever)
  5. Add 127.0.0.1 (your new localhost-based dnsmasq server) to your DNS servers list. I recommend adding it after a few other DNS servers because otherwise your local DNS if configured improperly can result in weird behavior on your machine
  6. If at this point you don't have 8.8.4.4 and 8.8.8.8 in your DNS list, I suggest adding them. They're google's DNS servers and they're quite reliable. Again, I put these above 127.0.0.1 but you do you.

Test

To see this working, open a new terminal window and type the following command (install dig if not present on your machine):

$ dig ip-172-23-53-101.ec2.internal

; <<>> DiG 9.8.3-P1 <<>> @127.0.0.1 ip-172-23-53-101.ec2.internal
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28487
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;ip-172-23-53-101.ec2.internal. IN  A

;; ANSWER SECTION:
ip-172-23-53-101.ec2.internal. 0 IN A 172.23.53.101

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Mar 13 19:25:03 2017
;; MSG SIZE  rcvd: 63

Source

I originally took this from ashee but modified it to work on modern OS X and changed a few things for clarity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment