Use dnsmasq to setup DNS server for TCP testing

In https://luohuahuang.org/2018/08/23/mitmproxy/ I introduced a tool to setup HTTP(s) proxy to test our new server. Our Android client is using HTTPS protocol, however our iOS client is using TCP protocol. mitmproxy is for HTTP(s) protocol only.

Found one tool https://gist.github.com/ogrrd/5831371 for this purpose.

Follow steps on https://gist.github.com/ogrrd/5831371 and http://www.natemcintyre.com/blog/2016/8/25/configuring-your-own-dns-server-on-mac-os-x to setup

  1. brew install dnsmasq
  2. mkdir -pv $(brew –prefix)/etc/
  3. echo ‘address=/.dev/127.0.0.1’ > $(brew –prefix)/etc/dnsmasq.conf
  4. sudo cp -v $(brew –prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist /Library/LaunchDaemons
  5. sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist
  6. sudo mkdir -v /etc/resolver
  7. sudo bash -c ‘echo “nameserver 127.0.0.1” > /etc/resolver/dev’
  8. Configure hostname to IP address mapping via the local hosts file.
    1. Command: vim /etc/hosts
    2. This step can vary depending on how you have ‘dnsmasq’ configured, but with default configurations the software will look to the servers /etc/hosts file to serve as the hostname/ip registrar.
  9. System Preferences > Network > Wi-Fi (or whatever you use) > Advanced… > DNS > add 127.0.0.1 to top of the list.
  10. Image Pasted at 2018-8-23 17-05.png