Dnsmasq
From WL-HDD Wiki
| WL-HDD Contents |
|---|
| What is the WL-HDD |
| Features |
| Pro's/con's |
| Reviews |
| Hacking |
| Inserting the HDD |
| Hacking Guides |
| Basic setup guides |
| Packages guides |
| Requests |
| Troubleshooting |
| This Wiki |
| Credits |
| Editing help |
| Contact Me |
Contents |
Prerequisites
To complete this guide, the following is assumed:
| You are running Oleg's firmware (1.9.2.7-6b or later) |
| You have harddisk partitions up and running with an extended filesystem mounted to /opt |
| You have installed the Ipkg package system. |
| You have configured your partitions to automount. |
dnsmasq is DNS server and forwarder. It allows you to set up your on DNS server on your LAN. The DNS server will resolve queries using external DNS server (of your ISP) and you can add more DNS records to it. It is usefull if you experience problems with resolwing of Windows computer names. dnsmasq home is http://www.thekelleys.org.uk/dnsmasq/doc.html.
Instalation
CD to somewhere on your HDD
cd /opt
Download the package (check http://ipkg.nslu2-linux.org/feeds/unslung/wl500g/) for list of packages and version numbers).
wget http://ipkg.nslu2-linux.org/feeds/unslung/wl500g/dnsmasq_2.15-6_mipsel.ipk
Install the package from file
ipkg install dnsmasq_2.15-6_mipsel.ipk
Reboot to check if dnsmasq will start automatically.
reboot
List processes to check if dnsmasq is running
ps
One of listed processes should be /opt/sbin/dnsmasq
Now test if dnsmasq works. You need to change DNS server of your computer to WL-HDD. For example in Windows Vista you can do this this way (for wireless connection):
- Start | Control Panel | Network And Internet | Network And Sharing Center
- Select your wireless connection and click View status | Properties (confirm UAC prompt)
- Select Internet Protocol Version 4 (TCP/IPv4) and click Properties
- Check Use following DNS server addresses and type down IP address of your WL HDD (i.e. 192.168.1.220)
- Confirm OK and Close to change take effect
- Run Windows command prompt (WinKey+R and type cmd)
- Type nslookup
It should show somethign like:
D:\users\Honza>nslookup Default Server: UnKnown Address: 192.168.1.220
Where address if IP of your WL-HDD Type google.com. (do not forget the trailing dot) and press enter. You should see somethign like
> google.com.
Server: UnKnown
Address: 192.168.1.220
Non-authoritative answer:
Name: google.com
Addresses: 64.233.167.99
64.233.187.99
72.14.207.99
OK, it works! Close the command prompt and revert your DNS settings to be obtained from DHCP (Start | Control Panel | Network And Internet | Network And Sharing Center | <Your network> | View status | Properties | UAC OK | Internet Protocol Version 4 (TCP/IPv4) | Properties | Obtain DNS server address automatically).
Adding your own names
The names are stored in /etc/hosts file. This file is not on hdd but in flashfs. So, you have 2 options: Change dnsmasq configuration file in orderto use file from HDD or edit and save /etc/hosts. I'll use /etc/hosts. First you need to make /etc/hosts to be commited to flashs when commit is done. As stated in Committing to flash, type
echo "/etc/hosts">>/usr/local/.files flashfs save
Check if /etc/hosts is in list and continue
flashfs commit flashfs enable
Now lets setup host. Open /etc/hosts
nano /etc/hosts
You will see something like
127.0.0.1 localhost.localdomain localhost 192.168.1.1 dzonny-AP my.router my.WLHDD
And now you can add your own servers. Type something like this:
192.168.1.1 dzonny 192.168.1.2 papik 192.168.1.3 old 192.168.1.5 noutbuk 192.168.1.254 router
When finished save your work (Ctrl+O) and quit nano (Ctrl+X). Than commit changes to flasfs.
flashfs save flashfs commit flashfs enable reboot
Client configuration
Finally you have to force all client computers to use your new DNS server. You can do it in way provided above when we were testing if dnsmasq works. But it is better to setup DHCP server that provides IPs to your computers to provide DNSs as well. It probably does so by now, so the only think you need is change DNS server address. There are 2 possible scenarios:
- WL-HDD is your DHCP
- unfortunalelly I don't know if DHCP server that is running on WL-HDD can be configured via web interface as I'm not running this scenario
- All you need is modify DHCP server setting to provde itself as DNS
- It is also possible to use dnsmasq as DHCP
- You have another DHCP server in your network (probly your home gateway router with NAT)
- You should configure the server to provide WL-HDD as DNS (its somewhere in DHCP settings)
- If WL-HDD obtains settings via DHCP from that server, you must change DNS server setting of dnsmasq. Otherwise WL-HDD will become forward DNS server for itself and you will no longer be able to resolve external DNS names.
- This can be done be editing /opt/etc/dnsmasq.conf
- Open it with nano and locate resolv-file setting. Change it to /opt/etc/resolv.conf
- Save and close nano
- Now create the resolv.conf file in /opt/etc (nano /opt/etc/resolve.conf)
- Type there soemthing like 'nameserver 213.46.172.36' with IP address of DNS of your ISP. If your ISP provides more DNS servers, write more lines in tbe file.
- Save and close nano
- Restart dnsmasq /opt/etc/init.d/S56dnsmasq restart
Then force your computer to read new setting from DHCP (i.e. disconnect and reconnect to network).
And then test the configuration. Run windows command prompt and type nslookup. You shold see somethink like
D:\users\Honza>nslookup Default Server: dzonny-AP Address: 192.168.1.220 >
Then type google.com. (with trailing dot). You should see soemthing like:
> google.com.
Server: dzonny-AP
Address: 192.168.1.220
Non-authoritative answer:
Name: google.com
Addresses: 64.233.167.99
72.14.207.99
64.233.187.99
In case of troubles here edit dnsmasq.conf. Locate #server line and type server=213.46.172.36 with IP of primary nameserver of your ISP and restart router. Then try to resolve your own compuer name (do not forget trailing dot). Then you may try various pings.
Summary information
- dnsmasq configuration file /opt/etc/dnsmasq.conf
- dnsmasq startup command /opt/etc/init.d/S56dnsmasq
- which DNS server are used for forwarding? /etc/resolv.conf (file can be changed in dnsmasq.conf; WL-HDD maintains this file to be in sync with DNS configuration of WL-HDD)
