Slackware This Forum is for the discussion of Slackware Linux.
|
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-01-2006, 09:33 PM
|
#1
|
Member
Registered: Dec 2005
Distribution: Slackware
Posts: 41
Rep:
|
Hosts file entry with DHCP
I've got my pc set up for DHCP from my cable router. For some reason though, the slackware net scripts assign the loopback IP to my hostname in /etc/hosts, despite the hosts file actually saying that it causes problems. Lo and behold, it causes me problems, with a certain Java API call to get the local IP that always returns the local LAN address on any other OS.
The IP that I normally get from the router is 192.168.0.33, and that's what should be assigned to my hostname in /etc/hosts. I could set up a script to edit it every time I get an IP, but that really shouldn't be necessary. Solution anyone?
/etc/hosts (snipped a bit)
Code:
# 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. :^)
#
# For loopbacking.
127.0.0.1 localhost
127.0.0.1 mulbox.bigpond.net.au mulbox
/etc/rc.d/rc.inet1 (relevant part)
Code:
# Config information for eth0:
IPADDR[0]=""
NETMASK[0]=""
USE_DHCP[0]="yes"
DHCP_HOSTNAME[0]="mulbox"
|
|
|
02-02-2006, 01:22 AM
|
#2
|
Senior Member
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507
Rep:
|
I'd suggest to leave out the "127.0.0.1 mulbox.bigpond.net.au mulbox" from /etc/hosts, for the reasons stated in the remarks at the top of that file.
|
|
|
02-02-2006, 06:59 AM
|
#3
|
Member
Registered: Dec 2005
Distribution: Slackware
Posts: 41
Original Poster
Rep:
|
If I remove the line, it causes more problems than it solves, because then programs can't lookup my hostname in the hosts file. If I change the address to the address I normally get from DHCP, everything works fine, but that's obviously not a solution because DHCP is supposed to be dynamic, changeable, yada yada. What I think should really happen is I add some lines to rc.inet1 that place the correct entry in the hosts file. But shouldn't that be a part of the slackware distro to begin with, and I need to file some kind of bug report? Or is there some plain solution that I'm too n00b to see?
|
|
|
02-02-2006, 09:13 AM
|
#4
|
Senior Member
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507
Rep:
|
I am convinced that you should leave out this line to start with. It is an improper solution and you need to solve the problem correctly. I have never added this type of line in my hosts file and I have always managed to get an IP from the dhcpd.
Which program do you use which looks up the hostname this way?
|
|
|
02-02-2006, 11:18 PM
|
#5
|
Member
Registered: Dec 2005
Distribution: Slackware
Posts: 41
Original Poster
Rep:
|
I didn't add the line, it was present after I installed slackware. I know that programs should use a better technique to find out the local IP. The program that I'm using is Mercury, a Java-based MSN messenger client; and in fact it uses a simple Java API call to get the local IP, so it's many Java-based programs that may have this problem. There are other ways to do so within Java, and I'm trying to get the author to use one of these methods to solve the problem. However, the fact that it was wrong to begin with without my intervention is something that needs to be fixed, no?
|
|
|
02-03-2006, 05:30 PM
|
#6
|
Senior Member
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507
Rep:
|
This is how my /etc/hosts looks on a fresh 10.2 install with static IP:
Code:
#
# hosts This file describes a number of hostname-to-address
# mappings for the TCP/IP subsystem. It is mostly
# used at boot time, when no name servers are running.
# On small systems, this file can be used instead of a
# "named" name server. Just add the names, addresses
# and any aliases to this 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. :^)
#
# For loopbacking.
127.0.0.1 localhost
192.168.1.13 slackb102.internal.pu slackb102
# End of hosts.
This makes me believe that during installation you actually entered 127.0.0.1 as your static IP address. Is that possible?
|
|
|
02-04-2006, 12:47 AM
|
#7
|
Member
Registered: Dec 2005
Distribution: Slackware
Posts: 41
Original Poster
Rep:
|
Nope, definitely not possible. I had the line removed from /etc/hosts as you suggested and I just tried the netconfig script again. Lo and behold, the line reappeared.
Line 158 (part of write_config_files) puts the line in there, correct in your case but not in mine:
Code:
$IPADDR $HOSTNM.$DOMAIN $HOSTNM
In the case of DHCP though, IPADDR stays as the default of 127.0.0.1 from line 263 (the main code section):
I'm not a script fiend so I don't really know how to fix it, or even what to do to fix it :P
|
|
|
02-04-2006, 04:13 AM
|
#8
|
Senior Member
Registered: Oct 2004
Location: Luxemburg
Distribution: Slackware, OS X
Posts: 1,507
Rep:
|
You're right. I reconfigured my machine with DHCP and got the same line in my /etc/hosts. I commented it out again, and `hostname` is still giving the correct hostname despite the line now missing from /etc/hosts, even after a reboot.
So it appears that the line does no harm, and that it's "just" an application problem you are experiencing. The solution being that the application gets the hostname from the `hostname` command or the correspondant API and _not_ from the /etc/hosts file.
|
|
|
All times are GMT -5. The time now is 03:54 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|