Solved

setting resolvable hostname on a Linux laptop

Posted on 2006-06-10
9
313 Views
Last Modified: 2010-03-18
Hello,

The problem is this: how to set host name for a laptop running Linux
(Fedora Core 4, although the question is more general) such that the
name can be resolved successfully in all circumstances. The assumption
is that the laptop acquires IP address using DHCP protocol.

By `all circumstances' I mean that the name should be resolved on any
network that the laptop is connected to, as well as when it is not
connected to any networks.

By `name being resolved successfully' I mean that a command such as

$ ping laptop

should succeed, where `laptop' is the machine's hostname.

Needless to say, setting the host name in /etc/hosts file doesn't
work, since the IP address changes.

Any ideas?

Thanks for your help,

Ljubomir

0
Comment
Question by:ljubomir_buturovic
  • 5
  • 4
9 Comments
 
LVL 57

Expert Comment

by:giltjr
ID: 16880947
Which DHCP server are you running and which level?
What DNS server are you running and which level?

Most DHCP server that are being distributed today support telling a DNS server, "Hey I just gave IP address x.x.x.x. to host name a" and most DNS servers today support accepting this command.  It is called dynamic DNS (DDNS).
0
 

Author Comment

by:ljubomir_buturovic
ID: 16881433
Hi,

The DHCP server depends on the network that the laptop is connected to. When I'm at home, DHCP service is provided by the router. which obviously I can
configure to use DDNS. However, at work, or other locations such as airports, I don't have control over the DHCP server, and so I cannot configure it to use DDNS.
I could perhaps use a software DDNS client, if that's what you are suggesting - please clarify.

I am not running any DNS servers on the laptop. The list of DNS servers to use is provided by the DHCP server upon connecting to a network, and is stored in file
/etc/resolv.conf.

Regards,

Ljubomir
 
0
 
LVL 57

Expert Comment

by:giltjr
ID: 16881815
You can't do this for every network you connect to.   For you work network, you work DHCP and DNS server must be setup for this.  

When you are at home, your home DHCP and DNS server must be setup for this.   Further more when you are at home you need to decide if you want to ping within your private network, from the public Internet (meaning do you want me to ping you by host name), or both.

When you connect to public network, like the airport, you are limited to what they provide.

Why would you want somebody to be able to ping your computer by its name when you are connected to a public network (like the airport)?
0
 

Author Comment

by:ljubomir_buturovic
ID: 16881979
Thanks for your feedback. I think I was not sufficiently clear in my original posting. The situation is this: I don't need anyone outside my computer to ping it.
I only need to ping the laptop from that same laptop. In other words, I need this to work:

$ ping laptop

only from the laptop, that's all.

As to why, a short answer is: Matlab (a commercial software package for scientific computation).  For some reason, Matlab licensing daemon pings
the computer it is running on, by name. In other words, it executes the above ping command internally. If that fails, Matlab doesn't start. As it stands, right now I can
only use it on my laptop when I'm connected to my home network, which sort of defeats the purpose of using a laptop.

Perhaps this is not possible, and Matlab can really only function on stationary computers. Pretty bad for a software costing thousands of dollars, but that's a
different story. In any case, hopefully the context is clearer now.

Regards,

Ljubomir


0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 57

Expert Comment

by:giltjr
ID: 16881986
O.K. then it is simple.  Edit your hosts file, there should be a line like:

     127.0.0.1     localhost

change it to:

     127.0.0.1     localhost laptop

where laptop is the name of your laptop.  Now whenever you ping the name laptop it will reslove to the IP address 127.0.0.1, which is the local loopback address.
0
 

Author Comment

by:ljubomir_buturovic
ID: 16882012
Alright, that makes sense, except for one thing. What do you think about this comment in the /etc/hosts file:

#
# By the way, Arnt Gulbrandsen <agulbra@nvg.unit.no> says that 127.0.0.1
# should NEVER be named with the name of the machine.  It causes problems
# for some (stupid) programs, irc and reputedly talk. :^)
#

In other words, the comment says this should not be done. Do you understand why?

Ljubomir

0
 
LVL 57

Accepted Solution

by:
giltjr earned 500 total points
ID: 16882112
Yes, I understand why.  Some programs (stupid ones) will find out the comptuer name and then do a name resolution to find the comptuer IP address.  Depending on what they use this IP address for, will depend on if it causes a problem.  For the most part, if you are beind a firewall that is doing NAT these same programs will also have problems.

IRC, and other "IM" type programs allowed "private" direct computer  to computer chats.  To do this, each comptuer had to know the other computers IP address.  

Say you and I wanted to have a private IRC/IM type chat.  Well what do you think would happen if your computer told my computer that your IP address was 127.0.0.1?  Will my computer would try and talk to 127.0.0.1.  Not so good because I would be talking to myself (which I actually do a lot, but that is another issue).

However, you have the same exact issue if you are behind a firewall that does NAT.  You computer would tell me it's private IP address, and I would try and talk to that, but that will not work on the Internet.

So, there could be some issues with some programs (stupid one), but the only way to know if it causes problems it to try it.  
0
 

Author Comment

by:ljubomir_buturovic
ID: 16883059
I tested the functionality when connected to various networks, as well as away from any networks, all works.

Thanks,

Ljubomir
0
 
LVL 57

Expert Comment

by:giltjr
ID: 16885071
Great, hopefully you will not run into any issues.  Most programs now realize that they need to do things differently because of NAT.  At one time NAT, 10+ years ago, was not as prevelent as it is now and so most programs have realized they can't always depend on the hosts "real" IP address.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

762 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

23 Experts available now in Live!

Get 1:1 Help Now