This tutorial shows how to install and configure local DNS in Ubuntu,and make your Firefox/Opera web browser runs faster.
Install dnsmasq
OpenĀ  a terminal window(Applications/Accessories/Terminal) and type this to install dnsmasq:

sudo apt-get install dnsmasq

Configure dnsmasq
1. Edit /etc/dnsmasq.conf:

sudo gedit /etc/dnsmasq.conf

Find the line “#listen-address=” (without quotes),delete the “#” and change it to:

listen-address=127.0.0.1

Find the line “# resolv-file=”(use Search->Find,type to search),replace this with:

resolv-file=/etc/resolvconf/update.d/dnsmasq

then run:

sudo cp /etc/resolv.conf /etc/resolv.dnsmasq.conf

2.Edit /etc/dhcp3/dhclient.conf:

sudo gedit /etc/dhcp3/dhclient.conf

Find this line “#prepend domain-name-servers 127.0.0.1;”,and delete the “#”.
3.Edit /etc/resolv.conf:

sudo gedit /etc/resolv.conf

add following as the first line:

nameserver 127.0.0.1

4.Edit dsl-provider:

sudo gedit /etc/ppp/peers/dsl-provider

if there’s no this file(content is blank),use this:

sudo gedit /etc/ppp/peers/provider

add “#” (without quotes) at the beginning of:

usepeerdns

Test:
First,restart dnsmasq:

sudo /etc/init.d/dnsmasq restart

Try this twice and see effect:

dig g.cn

Configuring Firefox/Opera web browser

In Firefox or Opera window,go to Edit->Preferences,select Advanced->Network and click on Settings.
dns

Check “Manual proxy configuration:”->”No proxy for:localhost,127.0.0.1″.Click on OK
dns1