Skip to content

Instantly share code, notes, and snippets.

@senthilsweb
Last active October 31, 2021 01:09
Show Gist options
  • Save senthilsweb/6974c804e4ce31943b9138d1ec75e763 to your computer and use it in GitHub Desktop.
Save senthilsweb/6974c804e4ce31943b9138d1ec75e763 to your computer and use it in GitHub Desktop.

How to create Fake DNS in Mac OS for Local Kubernetes Ingress testing

Often times we need a way to simulate local domain name pointing to your local api or web development and it is critical if you use kubernetes ingress controller or traefik proxy to test your configuration in yoou local Mac laptop.

create a new ip

sudo ifconfig lo0 10.0.0.1 alias

Tunnel or forward 10.0.0.1:80 to custom port to your localhost. In this case, post 3000

echo "rdr pass on lo0 inet proto tcp from any to 10.0.0.1 port 80 -> 127.0.0.1 port 3000" | sudo pfctl -ef -

Then edit your /etc/hosts or /private/etc/hosts file and add the following line to map your domain zypress.me to 10.0.0.1

10.0.0.1 zypress.me

After you save your hosts file flush your local DNS. See references section below

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Access application using the local fake dns http://zypress.me

How to Delete the just created ip?

sudo ifconfig lo0 10.0.0.1 -alias

References

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