Use hostnames to connect to machines on LAN

4

1

I have just had my broadband upgraded to FTTC which means my router has had to change. Previously I was using a Thomson TG585v7 ADSL thingy provided by my ISP. One nice thing about that router was that it would act as a local DNS and allow me to find my other machines on the network by using <hostname>.lan instead of IP addresses.

I've now switched to a Linksys WRT320N ethernet router which connects to my fibre modem, and which I've updated to the latest firmware (1.0.04). I have 2 machines on the network which I regularly want to connect to each other; one is running Windows 7 and the other is running OS X Lion.

The problem I'm having is that I'm unable to connect to my Win7 machine from the OS X machine using the Win7 machine's name. However, I'm able to ping the OS X machine from my Win7 machine using the hostname.

alimbada

Posted 2011-07-28T11:54:37.037

Reputation: 75

possible duplicate of How can I get my home machines to connect to each other via hostname?

– Ƭᴇcʜιᴇ007 – 2015-02-24T17:46:04.663

Answers

2

It is very unusual for one of these routers to act as a local DNS server, but that is a really nice feature. Short of setting up a new DNS server (I checked your manual and you indeed so not have this feature for your new router), the simplest thing to do really is to give them static IP addresses, and add entries to the HOSTS file for each.

It is fast, easy and effective.

The other way, and I am not a Mac expert, would be to ask a new question about how to enable NetBIOS name service (It has to do with enabling Samba).

KCotreau

Posted 2011-07-28T11:54:37.037

Reputation: 24 985

I've set up an entry in /etc/hosts on my Mac to point to my Win7 machine for now, but I was hoping I wouldn't have to go this route. The Mac is a laptop so if I'm roaming and connect to another network I have to remember to kill anything that tries to automatically connect to my Win7 machine. I'm also not a fan of setting up static addresses because that also means using a static DNS (on Windows at least) – alimbada – 2011-07-28T13:06:26.287

@alimbada Then I would consider this question closed, and ask the other one about setting up a Mac to use NetBIOS (should be separate). You need either that, HOSTS, or to set up your own DNS server. There are no other options. – KCotreau – 2011-07-28T13:16:42.177

Fair enough. Also, I should have mentioned I already checked on NetBIOS and it's already enabled, running and on the same workgroup as my Win7 machine so that doesn't seem to help. Looks like static IP and hosts file it is for now. – alimbada – 2011-07-28T13:21:36.493

Try one more thing then: Disable both firewalls and check it that way. They could be blocking NetBIOS. – KCotreau – 2011-07-28T13:32:44.143

3

There are basically two name based access methods used in many home environments.

  1. A router as your WRT320N or TG585v7 uses a dedicated domain such as lan to provide by-name access to every computer that picked up a DHCP lease at the router. The router usually also propagates lan as a search domain to the clients (will show up as domain lan or search lan in the /etc/resolv.conf file of your Mac client for example), so that you don't even need to use the .lan prefix when using other computers host names.

  2. Multicast DNS is a server-less method, highly used by Apple but also implemented in Linux (avahi) and Windows. It allows you to access other hosts by the domain .local. Instead of asking a configured name server, when trying to resolve a .local hostname your computer simply broadcasts the request in the local network and some computer might reply with "hey, thats my name, here, thats my IP address"

The latter often works out of the box (if you have multiple Mac's on the network you can definitely use that method to address them, thats also the way they "discover" each other so you can use file sharing etc. through Finder). In your case, mDNS is probably what makes it possible for you to resolve your Macs name from the Windows machine. Your windows however does not seem to reply to mDNS requests (probably firewalled? Can' really help here, don't use Windows anywhere)

If you want the first (more controlled method) you need to check your routers firmware on how to enable that feature. If your routers firmware doesn't support that feature you might want to try using OpenWRT instead of the stock firmware.

barbaz

Posted 2011-07-28T11:54:37.037

Reputation: 2 696

Yeah, I already tried all those variations from my Mac - .lan, .local and without the suffix too. I keep getting `ping: cannot resolve <host>: Unknown host – alimbada – 2011-07-28T13:01:22.963

I don't know how good the windows support for the whole zeroconf thing is. Maybe it can only resolve others names, but doesn't provide it itself. For a more solid solution you probably want to go the DNS server way, i.e. try to enable that on your router – barbaz – 2011-07-28T13:06:59.690

I think I'll eventually be going the OpenWRT/dd-wrt route. That was the main reason I bought this particular router in the first place. – alimbada – 2011-07-28T13:27:28.467

I can only recommend that. dnsmasq (the daemon used for DHCP and DNS on OpenWRT systems) will provide you with your hostnames by default. If possible stay away from dd-wrt and choose OpenWRT if the device is sufficiently supported. – barbaz – 2011-07-28T18:34:37.307