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:


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 MatzTechnical SupportAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:
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. .
Julian MatzTechnical SupportAuthor 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

I installed avahi-daemon on my Ubuntu virtual machine, but I can't seem to get it working.
Check Out How Miercom Evaluates Wi-Fi Security!

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom on how WatchGuard's Wi-Fi security stacks up against the competition plus a LIVE demo!

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.
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.
Julian MatzTechnical SupportAuthor 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:


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.
Julian MatzTechnical SupportAuthor 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	23 hours, 21 minutes, 59 seconds

Open in new window

I still cannot ping the hostname though.
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.
Julian MatzTechnical SupportAuthor 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.
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.
Julian MatzTechnical SupportAuthor 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: IN A
* IN A

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, 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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian MatzTechnical SupportAuthor 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!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.