Difference between revisions of "Dnsmasq"
m (→Start the Daemon)
|Line 66:||Line 66:|
==Start the Daemon==
==Start the Daemon==
Dnsmasq as a daemon. To start it :
Revision as of 03:04, 11 March 2010
Dnsmasq provides services as a DNS cacher and a DHCP server. As a Domain Name Server (DNS), it can cache DNS queries to improve connection speed to previously visited sites. As a DHCP server, Template:Package Official can be used to provide internal IP addresses to computers on a LAN. Either or both of these services can be implemented. Dnsmasq is considered to be lightweight and easy to configure, and is designed for personal computer use or for use on a network with less that 50 computers.
Dnsmasq is in the official repositories and can be installed by:
pacman -S dnsmasq
DHCP Server Setup
The Dnsmasq configuration file needs to be configured (Template:Filename). The necessary configurations and their descriptions are as follows:
# 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
DNS Cache Setup
If you set up Dnsmasq as a DHCP server, it is already setup to record DNS queries and relay them to an internal network. To set up dnsmasq as a DNS caching daemon on a personal PC, edit Template:Filename and add the listen address:
After you have configured Dnsmasq, you will need to tell your DHCP client to pre-pend the localhost address to the known DNS addresses file (Template:Filename). This sends all queries to dnsmasq first before trying to resolve them to an external DNS server. After your DHCP client is configured, you will need to restart the network for changes to take effect.
echo "nameserver 127.0.0.1" > /etc/resolv.conf.head
If you use dhclient, you will need to add to (or create) to 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, creating a new profile, and then choosing DHCP type as 'Automatic (specify addresses).' Addresses are usually entered in such form: Template:Codeline.
Start the Daemon
Dnsmasq runs as a daemon. To start it now:
To have dnsmasq to load upon startup, add dnsmasq to your daemons array in Template:Filename:
DAEMONS=(network dnsmasq ...)
To see if dnsmasq started properly, check the log; dnsmasq sends it's messages to Template:Filename.
Test DHCP Server
From the LAN client make sure you have the network set up to detect a route with DHCP and attempt to connect to the network.
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.
Additional tips for Dnsmasq.
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.