pacman -S dnsmasq
# Only listen to routers' LAN NIC. Doing so opens up tcp/udp port 53 to # localhost and udp port 67 to world: interface=<LAN-NIC> # dnsmasq will open tcp/udp port 53 and udp port 67 to world to help with # dynamic interfaces (assigning dynamic ips). Dnsmasq will discard world # requests to them, but the paranoid might like to close them and let the # kernel handle them: bind-interfaces # Dynamic range of IPs to make available to LAN pc dhcp-range=192.168.111.50,192.168.111.100,12h # If you’d like to have dnsmasq assign static IPs, bind the LAN computer's # NIC MAC address: dhcp-host=aa:bb:cc:dd:ee:ff,192.168.111.50
If you choose not to bind the interfaces, the domain port will need to be allowed in Template:Filename:
domain ALL : ALLOW
echo "nameserver 127.0.0.1" > /etc/resolv.conf.head #设置dns服务器为127.0.0.1
如果你使用dhclient，你添加或编辑 Template:Filename 文件：
prepend domain-name-servers 127.0.0.1;
Since the upgrade of NetworkManager to 0.7, Arch Linux now calls Template:Package Official directly instead of the common default with Template:Package Official. Because of the arguments set with Template:Package Official, it no longer sources the Template:Filename, and Template:Filename settings for insertion of name servers. There are two workarounds to fix this. The first would be to use NetworkManager with dhclient which can be found in Template:Package AUR. The second workaround would be to go into NetworkManagers' settings (usually by right-clicking the applet) and entering your settings manually. Depending on the type of front-end you use for NetworkManager, the process usually involves right-clicking on the applet, editing (or creating) a profile, and then choosing DHCP type as 'Automatic (specify addresses).' The DNS ddresses are usually entered in such form:
127.0.0.1, DNS-server-one, ....
DAEMONS=(network dnsmasq ...)
查看dnsmasq是否启动正常，检查 Template:Filename 日志文件。
Test DHCP Server
From a computer that is connected to the one with dnsmasq on it, configure it to use DHCP for automatic IP address assignment, then attempt to log into the network as you normally would.
Test DNS Caching
Do a DNS lookup and measure the time response (dig is part of the Template:Package Official package):
dig archlinux.org | grep "Query time"
Try it again to compare the result.
Prevent OpenDNS Redirecting Google Queries
To prevent OpenDNS from redirecting all Google queries to their own search server, add to Template:Filename:
Replace X.X.X.X with your ISP's DNS server/Router IP.