I'm working on setting up a home intranet for me and my roommates. My idea is that we'll be able to store things like past utility bills in a place that's more accessible than a drawer in the kitchen etc. Anyway, I have Apache 2 running on a Raspberry Pi, on my LAN, and if I use its IP address, I can access pages being served on the Pi. Since I'm doing this project more to learn about networking as to provide a service to my apartment, I thought it would be cool if my network could provide hostname resolution for my LAN. So rather than point my browser to
192.168.1.151, the Pi's IP address, I could point it to
oberon (its hostname) and view the web pages served by the Pi.
Now I knew I was not the first person to want to do this, so I started by Googling. This question, also on Unix & Linux, has helped me immensely: How to make a machine accessible from the LAN using its hostname. At this point, I've tried everything in the verified answer. I thought about using the
hosts file, but that would mean I would have to tell my roommates to configure their machines, which I don't want to them to have to do. I tried to reserve a DHCP lease for the Pi on my router (a NETGEAR WNR1000v2 (aka an N150)), and while the reservation worked, hostname resolution does not. This kind of frustrates me because I told my router the IP of the Pi and its hostname, yet it still does not provide this information to clients on my LAN.
With these two methods not working, I decided to install
dnsmasq on the Pi. It seemed simple to configure and I would be happy to learn a new tool. I installed and have it running just fine (it seems). I can
nslookup the Pi's nicknames (which I set in
homenet) and get the correct results. I can do the same for internet names like
yahoo.com and get correct answers because I set up Google's
18.104.22.168 as backup servers in
/etc/dnsmasq.conf. See this:
me@oberon~$ dig oberon ; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> oberon ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10787 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;oberon. IN A ;; ANSWER SECTION: oberon. 0 IN A 192.168.1.151 ;; Query time: 10 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Sun Oct 6 18:59:18 2013 ;; MSG SIZE rcvd: 40
Note that the
oberon is looking up its own IP address on itself. This is what I expected to see. Output is the same if I do
dig oberon @localhost. Because of this output, I'm thinking that
dnsmasq is working fine. So to bring it to the next level, I want all clients on my LAN to be able to be able to type
oberon in their browser and be taken to
oberon's index page. For this I know I need to configure my router (apologies if this veers away from strictly Unix & Linux territory).
I have a Netgear WNR1000v2 that I am fairly familiar with. I have configured port forwarding so I can SSH into the Pi, and I've poked around in other settings as well. I know that before I started this project, I was getting my DNS servers from my ISP, but now I want to use those DNS servers primarily but also use
192.168.1.151 as a last check. So I changed my router's DNS config to the following:
So with this config, I expected to be able to do
nslookup oberon on my (Windows) desktop and get a result of
192.168.1.151. But this does not happen. This is what does happen:
C:\Users\me>nslookup oberon Server: UnKnown Address: fe80::226:f2ff:fefa:bea *** UnKnown can't find oberon: Non-existent domain
dnsflushing the network adapter on my Windows machine does not change anything.
Now here's why I'm kind of tearing my hair out here:
C:\Users\me>nslookup oberon 192.168.1.151 Server: oberon.lan Address: 192.168.1.151 Name: oberon Address: 192.168.1.151
dnsmasq is working just fine. If I tell my Windows box to use
192.168.1.151 to resolve the name
oberon, everything is fine (the
.lan domain was part of the configuration of
dnsmasq, so I expected to see it there). If I could just get my router to tell my Windows machine to use
192.168.1.151 when it makes DNS queries, I should be good!
So it seems to me that the problem is in my router, but I just can't figure out what to do beyond changing the DNS servers to include
192.168.1.151 like I already have. Can anyone help me here? I will try to provide any further information desired.