Route complete TLD (*.dev for example) to 127.0.0.1
In Ubuntu 12.10 or later you can do this with dnsmasq as run by NetworkManager.
Create the directory
mkdir /etc/NetworkManager/dnsmasq.d
if it doesn't already exist.sudo mkdir /etc/NetworkManager/dnsmasq.d
Toss the following line into
/etc/NetworkManager/dnsmasq.d/dev-tld
.address=/dev/127.0.0.1
(Ubuntu 12.10) Restart NetworkManager.
sudo service network-manager restart
(Ubuntu > 13.04) Restart Dnsmasq.
sudo service dnsmasq restart
Enjoy the awesomeness.
The complete standalone dnsmasq (DHCP and DNS server) is not installed by default in Ubuntu 12.04 and 12.10, but a package called dnsmasq-base is installed by default in Ubuntu Desktop 12.04 and 12.10. The dnsmasq-base package contains the dnsmasq binary and is used by NetworkManager.
To do what you want you will need to use dnsmasq as a caching DNS server. You need to:
- Install dnsmasq sudo apt-get install dnsmasq
- Change your network setting, so that your computer uses itself as it dns server.
- Make the changes to the config files:
Create /etc/dnsmasq.d/dev-tld
with these contents:
local=/dev/
address=/dev/127.0.0.5
The first command says *.dev
requests can't be forwarded to your real DNS server. The second says *.dev
resolves to 127.0.0.5
which is localhost.
- Restart the dnsmasq service (not network-manager)