Just wondering: Domain Name Really Required? Using 127.0.0.1 for the Machine Name?
SlackwareThis 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.
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.
Just wondering: Domain Name Really Required? Using 127.0.0.1 for the Machine Name?
Question 1:
When you configure networking under Slackware, you are prompted for the hostname that you want to assign to the machine, as well as a domain name. I have always found the requirement for the domain name a little strange; other Linux distribution can work without it, so why couldn't Slackware?
I decided to try and get rid of the domain name, and see if that might create any problems. Here's what I did:
I removed the domain name from the "/etc/HOSTNAME" file, so that just the (unqualified) hostname remained.
I removed the fully qualified hostname from the "/etc/hosts" file.
It seems to me that everything continues to work just normally. The "hostname" command continues to display the unqualified hostname, and the output from "hostname --fqdn" is now also the unqualified hostname.
Would there be any features that might run into problems now? I'll continue to run without a domain name for now, and see if anything breaks, but so far, everything seems to be perfectly OK.
Are there any specific reasons why the domain name should be required for Slackware, or could it have been made optional instead?
Question 2:
Under Slackware, the "/etc/hosts" file includes the following comment:
Quote:
# 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. :^)
Even so, the file does contain an entry that associates 127.0.0.1 with the hostname (both the unqualified and the fully qualified one). I have noticed, however, that Ubuntu, for example, defines address 127.0.1.1 (which ends in ".1.1" instead of ".0.1") for the hostname instead--which apparently works fine.
I have now modified my "/etc/hosts" file on my Slackware system, to associate the 127.0.1.1 address with the hostname, without any apparent ill effects.
I have no idea why using 127.0.0.1 for the hostname may cause any problems, but if it really is such a bad idea, then wouldn't it be more appropriate for Slackware to use the 127.0.1.1 address instead?
No - it's not a problem to omit the "domain" part of an fqdn ... if you don't happen to be part of a domain (if you're a standalone host, or just have two or three hosts on a small LAN). Personally, I think a better approach is to call your domain something like "mylan.local" ... and then make sure every host (including, and especially, any devices like a wifi base station or cable modem) all follow the same convention (assuming the devices allow to to configure an fqdn).
And yes, associating 127.0.0.1 with a hostname is OK. It's a bit bass-ackwards to assign your OWN hostname to loopback. But one example is to assign "HOSTB" to "127.0.0.1" if you want to PREVENT yourself from ever calling out to the "real" (external) "HOSTB". In other words, you can use "127.0.0.1" to "comment out" specific hostnames, if you need to.
And yes, associating 127.0.0.1 with a hostname is OK. It's a bit bass-ackwards to assign your OWN hostname to loopback. But one example is to assign "HOSTB" to "127.0.0.1" if you want to PREVENT yourself from ever calling out to the "real" (external) "HOSTB". In other words, you can use "127.0.0.1" to "comment out" specific hostnames, if you need to.
I wonder why Xfce seems to need this entry. There appears a message that Xfce might not work properly if there is no such entry in /etc/hosts.
You can leave it blank, or fill it in. It doesn't have to be a fqdn. Use whatever you want - Eg. local.lan , null.post , root.me , etc.
It will be needed if you use NFS, NIS, or similar network services.
Answer 2
127.0.0.1 is for loopback connections. Any address in 127.0.0.0/8 network range is mapped to 127.0.0.1. Therefore, associating 127.0.1.1 with the hostname is the same as associating 127.0.0.1 with this hostname.
Regardless, you should change your /etc/hosts file to match the following:
127.0.0.1 localhost
x.x.x.x hostname.domain hostname
^^^ replace this with whatever local IP that matches your environment. Eg. 192.x.x.x , 172.x.x.x , or 10.x.x.x
This isn't an area where you should be getting "creative". Just set it up right, and everything will work. I cannot think of any scenario where it would be beneficial to bork this file standard.
Just FYI, granth is absolutely correct on both counts. I said you *could* do these things (and you can), but I didn't necessarily imply that you *should*.
The only reason you'd want "127.0.0.1" "trick" is if you had an environment where sometimes you'd want "HOSTX" to be a real host, and other times you want to insure you CAN'T and WON'T communicate with it. One of my clients does this. And frankly, I think it's really less of a "trick" than a "hack". I would certainly discourage you from doing it unless you really needed to.
And as far as defining your own hostname as loopback: I don't see any problem (including with Xfce!) ... but I certainly wouldn't recommend it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.