Linux - how to set hostname and aliases

Hi! Some network devices, e.g. network printers, network attached storage devices, etc. can be accessed by their hostnames or network names. For example, I can access my printer's web interface by typing the following URL into my browser:

http://hp6980/

Could someone please explain to me how this is possible inside a private network? Normally, a DNS server would have the task of name resolution. However, in a private network such as mine, name resolution seems to work automatically, without having to set up and run a customised DNS server. All network clients connect through a default gateway, which is normally some type of broadband router. How do the individual network devices communicate their hostnames to this router (or to other network devices) so that name resolution can occur?

Does it have something to do with mDNS? How does this work?

I have an Ubuntu server, and I'd like to be able to access it via its hostname rather than using its IP address. How can I set this up properly, with or without static IP address? I think Avahi can be used to set this up, but I would like to understand it.
LVL 21
Julian MatzJoint ChairpersonAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Julian MatzConnect With a Mentor Joint ChairpersonAuthor Commented:
I think I understand what you're saying. I still think there must be a way to do it using mDNS, though I could be wrong.

Either way, I think it's too complicated, so I've come up with a better, easier solution... I used a registered TLD and set up the following A records on my live public DNS server with which the domain is registered:

ubuntu-server.lan.mydomain.com IN A 192.168.1.155
*.ubuntu-server.lan.mydomain.com IN A 192.168.1.155

When my network devices (or any device) now try to resolve this name, they will query the DNS server, and that will return the IP 192.168.1.155, which points to the Ubuntu VM inside my private network.

This makes it a lot easier, and I don't need to change my network configuration or set up an additional router or DNS server.
0
 
rindiConnect With a Mentor Commented:
These names are usually resolved by "wins". On Linux you need samba installed and some settings set in your nsswitch file. The Link below should help:

http://www.colingodsey.com/resolving-windows-host-names-netbios-samba-in-linux/
0
 
prerakgConnect With a Mentor Commented:
Local hostname resolution happens via hosts file in linux. In /etc/hosts file you can find the same.

with the hostname command you can change the hostname parameter. .
0
Building an Effective Phishing Protection Program

Join Director of Product Management Todd OBoyle on April 26th as he covers the key elements of a phishing protection program. Whether you’re an old hat at phishing education or considering starting a program -- we'll discuss critical components that should be in any program.

 
Julian MatzJoint ChairpersonAuthor Commented:
I think you misunderstood the question. I want to set up hostname discovery on my local network without the use of a DNS server. I think this can be done using mDNS and DNS-SD

http://en.wikipedia.org/wiki/Multicast_DNS

I installed avahi-daemon on my Ubuntu virtual machine, but I can't seem to get it working.
0
 
rindiConnect With a Mentor Commented:
As I mentioned, this is a so called wins service that does this. Just follow the instructions I posted in my Link above to get wins working, and you should be able to connect using the name. But the discovery process can take some time, it may not work immediately after you have installed and made the changes.
0
 
arnoldConnect With a Mentor Commented:
DNS, DHCP services are provided by the broadband router, look at the LAN client list and it should reflect the mac, IP and hostname of the system and would likely match and answer the question you asked.
Some newer routers flush the DHCP client list, so the existance is sparce.
Presumably all system reference the local broadband router as the DNS server.
As rindi pointed it might be through a netbios broadcasts to which the printers respond.
use a network monitoring tools such as networking monitor, or wireshark and see what packets are being sent out when you attempt to ping, access hp6980.
Access the printer interface and change its name to confirm.
0
 
Julian MatzJoint ChairpersonAuthor Commented:
My printer has the following under Networking -> mDNS:

mDNS Service Name: Deskjet 6980 series [5FDA5D]
mDNS Domain Name: HP6980.local.
mDNS Highest Priority Service: 9100 printing

The HP6980 part can be changed via Settings -> Hostname. The mDNS Service Name can also be changed.

My Buffalo LinkStation NAS is the same; instead of typing the IP address, I can access via this URL:

http://LS-WXL713/

Unfortunately though, I cannot access these devices via SSH to see how they are configured exactly.

Yes, all devices use the router's IP as their nameserver.

My Windows computers may use NetBIOS or WINS, but my printer and NAS use mDNS. Linux also uses mDNS, I just can't seem to get it working.

WINS and Samba won't help me. I want Ubuntu to broadcast its hostname to the rest of the network.
0
 
Julian MatzJoint ChairpersonAuthor Commented:
I called the Ubuntu VM ubuntu-server, with hostname ubuntu-server.local.

My router's list of connected clients shows following:

Host Name	MAC Address	IP Address	Expires In
ubuntu-server	08:00:27:71:AA:97	192.168.1.155	23 hours, 21 minutes, 59 seconds

Open in new window


I still cannot ping the hostname though.
0
 
arnoldConnect With a Mentor Commented:
Ssh has to be a service that is available and enabled.
The nas should be accessible via a browser port 80 or 8080 as applicable. The same for the printer. Have not looked at whether the two referenced items actually support ssh.
0
 
Julian MatzJoint ChairpersonAuthor Commented:
Don't think the printer has SSH running on it. NAS does but no access unless you flash the firmware or something. both devices are accessible via http on port 80.

I can also access the devices from Ubuntu, by the way, using their hostnames. I just can't access Ubuntu using its hostname from other network computers and devices.
0
 
arnoldConnect With a Mentor Commented:
One or both of the other experts have commented that you would need to configure samba on the ubuntu that will be listening for the netbios events and this is how your ubuntu will respond to requests for the name.
You could simplify things but configuring a DNS server on the UBUNTU server to which all your other stations will register and how you will be able to resolve internal names as well as external.
0
 
Julian MatzJoint ChairpersonAuthor Commented:
The solution, although a little different to the solution I thought I was looking for, turned out to be the best solution in my situation. I appreciate the help though, and have assigned points accordingly. Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.