Skip to content

Instantly share code, notes, and snippets.

@ashee
Last active May 19, 2022 07:19
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ashee/0535b6d09152f852578f474fcbece318 to your computer and use it in GitHub Desktop.
Save ashee/0535b6d09152f852578f474fcbece318 to your computer and use it in GitHub Desktop.
dnsmasq in osx (macSierra) to resolve aws internal ip's

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

$ brew install dnsmasq

Configure dnsmasq

$ cp /usr/local/Cellar/dnsmasq/2.76/dnsmasq.conf.example /usr/local/etc/dnsmasq.conf
$ vim /usr/local/etc/dnsmasq.conf # add following to the end of the file
.....
....
# ashee: 03/19/2017
# 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

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

Test to see it working

$ 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment