Setup of OpenDNS and dnsmasq (on Arch Linux)

OpenDNS

1. Stop auto update of /etc/resolv.conf by dhcpcd

dhcpcd is started from /etc/rc.d/network.
/etc/rc.d/network obtains the options of dhcpcd from /etc/conf.d/dhcpcd.
So, I edited /etc/conf.d/dhcpcd like this.

# /etc/conf.d/dhcpcd 
DHCPCD_ARGS="-q --nohook resolv.conf"

2. Edit /etc/resolv.conf

Set OpenDNS server.

# /etc/resolv.conf
nameserver 208.67.222.222
nameserver 208.67.220.220

3. Restart network

$ sudo /etc/rc.d/network restart

4. Check DNS

$ dig example.com |grep SERVER
;; SERVER: 208.67.222.222#53(208.67.222.222)

dnsmasq

1. Install dnsmasq

$ sudo pacman -Ss dnsmasq
$ sudo vi /etc/dnsmasq.conf
$ grep listen-address /etc/dnsmasq.conf
listen-address=127.0.0.1
$ sudo /etc/rc.d/dnsmasq start

And, I added dnsmasq to the DAEMONS line of /etc/rc.conf.

2. Edit /etc/resolv.conf

Add local dnsmasq server to top.

# /etc/resolv.conf
nameserver 127.0.0.1
nameserver 208.67.222.222
nameserver 208.67.220.220

3. Check DNS

$ dig example.com |grep SERVER
;; SERVER: 127.0.0.1#53(127.0.0.1)