Solved

Linux - how to set hostname and aliases

Posted on 2012-03-25
12
677 Views
Last Modified: 2012-08-09
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.
0
Comment
Question by:Julian Matz
  • 6
  • 3
  • 2
  • +1
12 Comments
 
LVL 87

Assisted Solution

by:rindi
rindi earned 184 total points
Comment Utility
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
 
LVL 2

Assisted Solution

by:prerakg
prerakg earned 50 total points
Comment Utility
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
 
LVL 21

Author Comment

by:Julian Matz
Comment Utility
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
 
LVL 87

Assisted Solution

by:rindi
rindi earned 184 total points
Comment Utility
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
 
LVL 76

Assisted Solution

by:arnold
arnold earned 266 total points
Comment Utility
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
 
LVL 21

Author Comment

by:Julian Matz
Comment Utility
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 21

Author Comment

by:Julian Matz
Comment Utility
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
 
LVL 76

Assisted Solution

by:arnold
arnold earned 266 total points
Comment Utility
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
 
LVL 21

Author Comment

by:Julian Matz
Comment Utility
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
 
LVL 76

Assisted Solution

by:arnold
arnold earned 266 total points
Comment Utility
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
 
LVL 21

Accepted Solution

by:
Julian Matz earned 0 total points
Comment Utility
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
 
LVL 21

Author Closing Comment

by:Julian Matz
Comment Utility
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

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I will assume you are running a non-server version of some sort of Windows throughout this article. There are many flavors of Windows since Windows Server 2000 - 2008, XP Home & Pro, Vista Home & Pro, and Windows 7 Starter, Home, Pro, Ultimate, etc.…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now