Changing location with dnsmasq

Recently I have been working on a new site, citytree. I’m doing some of the work on my laptop (asus eee 4g surf), I am sometimes in the same network as my repository (git through ssh), and sometimes on an external network. Previously I would go to the .git/config or .git/remotes and change the address before git push/git pull. That gets tiresome quick, and it isn’t even remotely the correct solution. The solution is to get the same name to resolve to two different ip’s, one when you are local and another when you aren’t. The way I did it, and the correct way I think (unless someone tells me otherwise), is through the dns server giving different responses. Since I already use dnsmaq, anyone with a dhcp lease is resolved correctly. So I switched the git server to be dhcp’d, told dnsmasq to give it the ip address which was previously static, and voila. This also means I’ve got a single dnsmasq.conf file to handle all the ip’s in my network, a big plus. In addition I made sure the same fqdn translated to the public ip I have (the same ip you’re reading this from), and now I have what I wanted!

Leave a Reply