How to resolve local domain name?

21

6

My Belkin router has an option to set a local domain name, which, I suspect, allows me to address hosts within my own network using this domain. By default, this is set to be "Belkin".

Is it possible to call hosts within my network like this, e.g. ping foobar.belkin instead of ping 192.168.2.4?

The thing is, my routers internal page shows all set hostnames (so dhclient seems to work) and the router itself is reachable as router.belkin, but no other hosts are.

My problem here is that the router knows each hosts name, but the hosts don't know each others name. How can I fix that?

Note: Nmap showed that port udp/53 for DNS is open on my router, but I can't find any way to configure it on the Web-interface.

Add:// It's a "Belkin F7D3302 v1"

MechMK1

Posted 2013-05-05T21:08:18.353

Reputation: 507

Well, can you ping the local clients by IP? – M.Bennett – 2013-05-05T21:43:03.800

Yes, without problem – MechMK1 – 2013-05-07T19:57:24.130

Though I can reach my FRITZ!Box using http://fritz.box, I access other machines on its network using .local rather than .box. Earlier, with another modem/router, it was .lan. – Arjan – 2013-05-14T20:44:03.557

I think we all got ahead of ourselves answering this question without actually knowing what Belkin product is being used. Which model router are you using? – Qwilson – 2013-05-15T13:09:59.007

Answers

11

In general the router won't act as a DNS server but they'll often act as a DNS proxy. That is, in DHCP they'll give out their own IP as the DNS server and then they'll turn around and hit the real DNS servers. If it's doing this then I'd think you could resolve those local, .belkin, names.

Check ipconfig /all and see if the Default Gateway and DHCP Server have the same IP. If not then enter nslookup, then enter "server ROUTER_IP" at the prompt and try to do a lookup on google.com. If that works then there's probably a setting in the router to have it give it's own IP as the DNS server that's not checked.

Dave Noonan

Posted 2013-05-05T21:08:18.353

Reputation: 359

14

If the machines on your LAN run a relatively modern operating system, then you can access them by appending ".local" to their host name, like this :

ping MACHINE_NAME.local

To get the name from a given IP, use

avahi-resolve-address MACHINE_IP

To see all connected machine names and IPs on the local network, use something like this BASH command :

px-lan-scan () {
    LOCAL_MASK=$(ip -o -4 addr show | awk -F '[ /]+' '/global/ {print $4}' | cut -d. -f1,2,3)
    GATEWAY=$(route -n | \grep '^0.0.0.0' | awk '{print $2}')
    if [ $1 ] ; then range=$1 ; else range="10" ; fi

    for num in $(seq 1 ${range}) ; do
        IP=$LOCAL_MASK.$num
        if [[ $IP == $GATEWAY ]] ; then MACHINE="gateway" ; else MACHINE=$(avahi-resolve-address $IP 2>/dev/null | sed -e :a -e "s/$IP//g;s/\.[^>]*$//g;s/^[ \t]*//") ; fi
        ping -c 1 $IP>/dev/null
        if [ $? -eq 0 ] ; then
            echo -e "UP    $IP \t ($MACHINE)" ; else
            echo -e "DOWN  $IP"
        fi
    done
}

yPhil

Posted 2013-05-05T21:08:18.353

Reputation: 1 261

1

The short answer is (for the most part) no. Your router (in most cases) is not a dns server. You can however set static entries for all of your devices and then add them to your host list within the given devices.

The Belkin F7D3302 does not support serving DNS.

Qwilson

Posted 2013-05-05T21:08:18.353

Reputation: 626

Yes this works, but this is the most undesirable option as it is very hard to maintain. And if the router changes any of the IPs it breaks. – b01 – 2015-12-26T22:45:05.413

You might very well be right, but all home-level modem/routers I have used (like SpeedTouch, FRITZ!Box) did come with some built-in DNS server. (Or at least, I could always use computer names rather than some IP address.) – Arjan – 2013-05-14T20:42:02.283

Well David is using a Belkin. He's mentioned that he does not see a place to configure dns settings within the router. My answer was based on the assumption (formed by the info given) that this router will not manage dns. – Qwilson – 2013-05-15T13:17:57.223

1

Sure, this is what I do with my router at home.

Your router should be able to do this as long as you have its DNS serving abilities turned on so that it processed DNS requests for the your LAN for that domain (it'll forward requests for other domains to your usual DNS servers such that your web browsing isn't broken on the clients).

You need to make each client use the router for their DNS lookups, which they likely will out the box assuming you're also using DHCP.

Sirex

Posted 2013-05-05T21:08:18.353

Reputation: 10 321

@Sirex I think key difference here is that ASUS router uses DDWRT for its firmware. That software is well known, as is OpenWRT, for providing great features like you would expect from a router – b01 – 2015-12-26T22:50:43.437

My router is a DHCP server, but I'm not sure if it is able to serve as DNS server. At least, I have found no such option – MechMK1 – 2013-05-07T19:58:36.713

i'd be surprised if it couldn't, to be honest. I'm using an asus router but with ddwrt firmware on it. Pretty sure it could do it out the box though. – Sirex – 2013-05-07T21:03:33.217

I have googled a little and couldn't find anything for Belkin routers – MechMK1 – 2013-05-09T10:56:27.373

1

I've had the exact same problem.

The problem seems to be that if you try to address a local host name, the router automatically appends ".belkin" assuming belkin is what you have set as your local domain name. Changing it to something else will not solve the problem and you can't leave this blank.

As xaccrocheur said above, most modern OSs will access most things by appending .local So... I have done a sort of work-around which works well with most of my machines. I changed the Local domain name setting on the router to local

I can now access MOST devices by host name only

Jenny

Posted 2013-05-05T21:08:18.353

Reputation: 11

0

Install and configure dns server within the local network, register it on all hosts, enter the internal dns server first in the list of dns servers on the Belkin router. Then you will have what you want.

STTR

Posted 2013-05-05T21:08:18.353

Reputation: 6 180

1I'd like to respectfully disagree with your answer. Placing a dns server in the network would be a solution, but given the fact David's question is specific to achieving dns through the router this is not an acceptable answer. – Qwilson – 2013-05-15T13:15:06.510

@Qwilson Gorgeous. Where, then, need to store and locate dns records for the local device? – STTR – 2013-05-15T13:35:05.940

For (most) local devices, there will be a host file for internal records, and a dedicated server for outside records (e.g. 8.8.8.8). – Qwilson – 2013-05-15T13:46:52.353

0

While I do not suggest doing this, it would give you the desired result (being able to ping local hostnames without setting up a separate DNS server)

  1. On your primary computer, browse to C:\Windows\System32\drivers\etc
  2. open the hosts file using notepad
  3. scroll to the bottom of your hosts file
  4. add a new line below the last commented line in the file that looks like this

192.168.2.1 router.belkin

192.168.2.2 hostname

192.168.2.3 hostname2

Save the hosts file.

Now try to ping hostname and hostname2, you should see the following

ping hostname2

Pinging hostname2 [192.168.2.3] with 32 bytes of data:

ping hostname

Pinging hostname2 [192.168.2.2] with 32 bytes of data:

Again, this is not how I would do it. I would opt to setup a DNS server myself, but if you do not have that option this is a quick and dirty alternative.

Oh dont forget if you plan on doing this, add yourself to the security permissions on the hosts file so you can write to the file. Also do not forget to copy this hosts file to all of the other machines on your network.

Richie086

Posted 2013-05-05T21:08:18.353

Reputation: 4 299