Skip to content

Latest commit

 

History

History
69 lines (53 loc) · 1.93 KB

setup-fake-dns.md

File metadata and controls

69 lines (53 loc) · 1.93 KB

Set up fake DNS

This tutorial will walk you through setting up DNS for the example.com domain. This guide is mainly for etcd testing.

The goal is to end up with the following DNS address usable for local testing:

$ dig +noall +answer SRV _etcd-server._tcp.example.com
_etcd-server._tcp.example.com. 300 IN	SRV	0 0 2380 etcd0.example.com.
_etcd-server._tcp.example.com. 300 IN	SRV	0 0 2380 etcd1.example.com.
_etcd-server._tcp.example.com. 300 IN	SRV	0 0 2380 etcd2.example.com.
$ dig +noall +answer etcd0.example.com etcd1.example.com etcd2.example.com
etcd0.example.com.	300	IN	A	10.0.1.10
etcd1.example.com.	300	IN	A	10.0.1.11
etcd2.example.com.	300	IN	A	10.0.1.12

The 10.0.1.x addresses are served by the upstream nameserver -- which is a real DNS nameserver (216.239.32.106) running on GCE.

Add IP aliases

$ sudo ifconfig en0 alias 10.0.1.10/32
$ sudo ifconfig en0 alias 10.0.1.11/32
$ sudo ifconfig en0 alias 10.0.1.12/32

Update resolve.conf

Add the following entry to /etc/reslov.conf

nameserver 216.239.32.106

The 216.239.32.106 is a Google DNS server that has been configured to serve the example.com Zone with a few helper records for etcd testing. Your resolv.conf should look something like this:

cat /etc/resolv.conf 
#
# Mac OS X Notice
#
# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.
#
# This file is automatically generated.
#
domain hsd1.or.comcast.net.
nameserver 216.239.32.106
nameserver 10.0.1.1
nameserver 2601:7:2100:7cf:22c9:d0ff:fe9d:fda1

Make sure the Google nameserver entry is at the top of the list.

Update /etc/hosts

To ensure tools that don't use the local resolver to work with out example.com domain add the following entries to your /etc/hosts file:

10.0.1.10 etcd0 etcd0.example.com
10.0.1.11 etcd1 etcd1.example.com
10.0.1.12 etcd2 etcd2.example.com