Hi,
I recently made a CentOS install on a machine with an unsupported network card. I had to add the driver for it later, once I finished the install. For now I have this:
[kikinovak@localhost ~]$ hostname --fqdn localhost.localdomain
Q: how would I change this to something like calimero.local?
Here's what I *would* do, but I prefer to ask before.
1) edit /etc/sysconfig/network and edit this line:
HOSTNAME=calimero.local
2) add a line to /etc/hosts like this:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 127.0.0.1 calimero.local calimero ::1 localhost6.localdomain6 localhost6
Please correct me if I'm wrong.
cheers,
Niki Kovacs
Hello,
you can do it from here. go through System >> Network >> Hosts
edit host name from here.
all things you have done till now are correct.
On Sat, Sep 13, 2008 at 11:36 AM, Niki Kovacs contact@kikinovak.net wrote:
Hi,
I recently made a CentOS install on a machine with an unsupported network card. I had to add the driver for it later, once I finished the install. For now I have this:
[kikinovak@localhost ~]$ hostname --fqdn localhost.localdomain
Q: how would I change this to something like calimero.local?
Here's what I *would* do, but I prefer to ask before.
- edit /etc/sysconfig/network and edit this line:
HOSTNAME=calimero.local
- add a line to /etc/hosts like this:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 127.0.0.1 calimero.local calimero ::1 localhost6.localdomain6 localhost6
Please correct me if I'm wrong.
cheers,
Niki Kovacs _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
Dear Niki.
- add a line to /etc/hosts like this:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 127.0.0.1 calimero.local calimero ::1 localhost6.localdomain6 localhost6
It should look like this:
127.0.0.1 localhost.localdomain localhost calimero.local calimero
Best Regards Marcus
Marcus Moeller a écrit :
- add a line to /etc/hosts like this:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 127.0.0.1 calimero.local calimero ::1 localhost6.localdomain6 localhost6
It should look like this:
127.0.0.1 localhost.localdomain localhost calimero.local calimero
I've been considering both syntaxes, and I wonder (with the scrupulousness of a medieval theologist) if there's any difference between them. And if so, what are the consequences?
Niki
Marcus Moeller a écrit :
It should look like this:
127.0.0.1 localhost.localdomain localhost calimero.local calimero
When I do this, I get the following result (after rebooting):
[kikinovak@calimero ~]$ hostname calimero.local [kikinovak@calimero ~]$ hostname --fqdn localhost.localdomain
This looks weird to me.
On Sat, 2008-09-13 at 11:31 +0200, Niki Kovacs wrote:
Marcus Moeller a écrit :
It should look like this:
127.0.0.1 localhost.localdomain localhost calimero.local calimero
When I do this, I get the following result (after rebooting):
[kikinovak@calimero ~]$ hostname calimero.local [kikinovak@calimero ~]$ hostname --fqdn localhost.localdomain
This looks weird to me.
IIRC, the 127.0.0.1 should normally have only the "localhost" thing.
$ cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost ::1 localhost6.localdomain6 localhost6
That's all I have in that file.
$ hostname centos501.homegroannetworking
$ hostname --fqdn centos501.homegroannetworking
$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 # VIA Technologies, Inc. VT6102 [Rhine-II] DEVICE=eth0 BOOTPROTO=dhcp HWADDR=xx:xx:xx:xx:xx:xx # I've masked out MAC address for this post ONBOOT=yes DHCP_HOSTNAME=CentOS501 TYPE=Ethernet USERCTL=no IPV6INIT=no PEERDNS=yes
If you are not getting your address from a DHCP server, there are minor differences.
<snip sig stuff>
HTH
William L. Maltby wrote:
HWADDR=xx:xx:xx:xx:xx:xx # I've masked out MAC address for this post
Out of curiosity why ? You are aware that someone knowing your MAC address outside your local network is fairly useless right?
I just find it funny how people tend to mask MAC/IP/host/domain names. If your system is not secure, and is on the internet, people on this list(and those scanning the archives etc) are the least of your worries.
for reference, my IP addresses are
DSL Line(retiring after 8 years, ISP says they are changing my IPs after they got bought out for the 3rd time since I've been with them): 216.39.174.24, 216.39.174.25, 216.39.174.26, 216.39.174.27,
Personal co-location (just moved my services from DSL to here in the past couple hours): 209.90.228.138, 209.90.228.139, 209.90.228.140, 209.90.228.141
and my cable modem IP is 24.16.137.131
MAC addresses: (OpenBSD firewall protecting my Cable and DSL lines) 00:03:47:08:a9:fe 00:03:47:08:a9:ff 00:02:b3:be:82:cc 00:02:b3:be:82:cd 00:02:b3:be:86:f4 00:02:b3:be:86:f5
MACs for servers on my DSL 00:0F:1F:72:15:3F 00:04:23:C0:09:BC 00:04:23:C0:09:BD 00:0C:29:13:58:14
(Same MACs on the migrated systems at co-location, they are virtual machines)
nate
On Sat, 2008-09-13 at 05:06 -0700, nate wrote:
William L. Maltby wrote:
HWADDR=xx:xx:xx:xx:xx:xx # I've masked out MAC address for this post
Out of curiosity why ? You are aware that someone knowing your MAC address outside your local network is fairly useless right?
Yes. I just do it out of habit so I don't forget something which could lead to exposure. Habit developed long ago.
I just find it funny how people tend to mask MAC/IP/host/domain names. If your system is not secure, and is on the internet, people on this list(and those scanning the archives etc) are the least of your worries.
Long, long ago, I had a block of IPs and registered domain. Worries about hacking were relatively new then, I was even more ignorant about this stuff than I am now, and my gateway/mail unit got hacked. I immediately split services, hardened the gateway and, in a continual process of "learning from my mistakes", decided that *always* masking some site-specific information would help reduce the chance that I would forget on some critical piece down the road. If nothing else, since I don't mask *all* site-specific data, it causes me to briefly think. Since "hoomons" are, indeed, creatures of habit, it is best to reinforce good habits, even to the point of overkill IMO.
I would rather do unnecessary work and be safer than be lazy and maybe get burned at the most inopportune time (seems to be the most common time for *everything* bad to happen).
<snip site information>
Since, as I've often stated, I'm really ignorant about a lot of stuff, I feel no regrets about taking a little more conservative approach to this sort of stuff.
nate
<snip>
Marcus Moeller a écrit :
It should look like this:
127.0.0.1 localhost.localdomain localhost calimero.local calimero
I slightly altered it:
[kikinovak@calimero ~]$ cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 calimero.local calimero localhost.localdomain localhost
[kikinovak@calimero ~]$ hostname calimero.local [kikinovak@calimero ~]$ hostname --fqdn calimero.local
Wouldn't this be more correct?
Dear Niki.
It should look like this:
127.0.0.1 localhost.localdomain localhost calimero.local calimero
I slightly altered it:
[kikinovak@calimero ~]$ cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 calimero.local calimero localhost.localdomain localhost
[kikinovak@calimero ~]$ hostname calimero.local [kikinovak@calimero ~]$ hostname --fqdn calimero.local
Wouldn't this be more correct?
This is hard to decide.
From Slackwares /etc/hosts:
... # 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. ...
From: http://lists.debian.org/debian-devel/2005/10/msg00387.html it should be set to:
127.0.0.1 localhost localhost.localdomain calimero calimero.local
Best Regards Marcus
Marcus Moeller a écrit :
From Slackwares /etc/hosts:
... # 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. ...
I'm familiar with that one. Been a long-time Slackware user before. Though lately I don't follow this caveat anymore, as I have yet to come across one of said stupid programs. And BitchX doesn't seem to mind.
Cheers,
NK
2008/9/13 Niki Kovacs contact@kikinovak.net:
Marcus Moeller a écrit :
From Slackwares /etc/hosts:
... # 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. ...
I'm familiar with that one. Been a long-time Slackware user before. Though lately I don't follow this caveat anymore, as I have yet to come across one of said stupid programs. And BitchX doesn't seem to mind.
I agree on that and Pat just add it as a notice. My advice is to set 'localhost' or 'localhost.localdomain' (which should not really matter but 'localhost' first is best practice) and all your other hostnames as aliases.
Of course it 'may' also work if you add two lines for 127.0.0.1 (Ubuntu did it that way just a while) but this is just because FCFS.
Concerning RH or CentOS: I have to define /etc/hosts on all machines that do not obtain their hostname via DHCP. I have not yet figured out that the HOSTNAME variable in /etc/sysconfig/network is used in any form (correct me if I am wrong).
Best Regards Marcus
Marcus,
on 2008/09/14 0:41, Marcus Moeller wrote:
Concerning RH or CentOS: I have to define /etc/hosts on all machines that do not obtain their hostname via DHCP. I have not yet figured out that the HOSTNAME variable in /etc/sysconfig/network is used in any form (correct me if I am wrong).
See /etc/rc.d/rc.sysinit. In that file you can find following lines
---- (snip)
if [ -f /etc/sysconfig/network ]; then . /etc/sysconfig/network fi
(snip)
# Set the hostname. update_boot_stage RChostname action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
(snip) ----
The ${HOSTNAME} variable comes form /etc/sysconfig/network.
Dear Shu.
Thanks for that explanation.
Concerning RH or CentOS: I have to define /etc/hosts on all machines that do not obtain their hostname via DHCP. I have not yet figured out that the HOSTNAME variable in /etc/sysconfig/network is used in any form (correct me if I am wrong).
See /etc/rc.d/rc.sysinit. In that file you can find following lines
(snip)
if [ -f /etc/sysconfig/network ]; then . /etc/sysconfig/network fi
(snip)
# Set the hostname. update_boot_stage RChostname action $"Setting hostname ${HOSTNAME}: " hostname ${HOSTNAME}
(snip)
The ${HOSTNAME} variable comes form /etc/sysconfig/network.
I still wonder why it also works if hostname is only set in /etc/hosts like:
127.0.0.1 localhost 10.0.0.50 myserver.domain.example myserver
and $HOSTNAME is undefined.
Best Regards Marcus
...
I still wonder why it also works if hostname is only set in /etc/hosts like:
127.0.0.1 localhost 10.0.0.50 myserver.domain.example myserver
and $HOSTNAME is undefined.
Ah, got it:
/etc/sysconfig/network-scripts/ifup-post
... if need_hostname; then IPADDR=`LANG= LC_ALL= ifconfig ${DEVICE} | grep 'inet addr' | awk -F: '{ print $2 } ' | awk '{ print $1 }'` eval `/bin/ipcalc --silent --hostname ${IPADDR}` if [ "$?" = "0" ]; the set_hostname $HOSTNAME fi fi ...
So the conclusion seems to be:
If you have a local interface only you should just set:
127.0.0.1 localhost ::1 localhost6
in /etc/hosts and
HOSTNAME=localhost
in /etc/sysconfig/network
This means it is not suggested to have a hostname other than localhost on a loopback only box.
If you have an network interface configured /etc/hosts may look like:
127.0.0.1 localhost ::1 localhost6 10.0.0.50 host.domain.example host
and
HOSTNAME=host.domain.example
in /etc/sysconfig/network
Best Regards Marcus
On Mon, Sep 15, 2008 at 12:41 PM, Marcus Moeller mm@gcug.de wrote:
So the conclusion seems to be:
If you have a local interface only you should just set:
127.0.0.1 localhost ::1 localhost6
in /etc/hosts and
HOSTNAME=localhost
in /etc/sysconfig/network
This means it is not suggested to have a hostname other than localhost on a loopback only box.
If you have an network interface configured /etc/hosts may look like:
127.0.0.1 localhost ::1 localhost6 10.0.0.50 host.domain.example host
and
HOSTNAME=host.domain.example
in /etc/sysconfig/network
I'm curious - I have a local 192.168.x.x subnet inside my firewall that I would like to give a name other than just "localdomain." Does it matter what I use, or are their words/pieces I should avoid? This is strictly for my internal subnet, not visible to the outside world at all.
Thanks.
mhr
I'm curious - I have a local 192.168.x.x subnet inside my firewall that I would like to give a name other than just "localdomain." Does it matter what I use, or are their words/pieces I should avoid? This is strictly for my internal subnet, not visible to the outside world at all.
Thanks.
mhr
Mhr,
If what you are asking is can you setup an internal dns name to IP address and IP address to name resolution and call it what you want...
yes you can
You can call it whatever you want.
Just do not use names that are "resolvable" in public IP address space or that would get you in trouble with the law for whatever reason.
I also suggest that you read up on the mechanics of having machines you control that do both public and private dns
- rh
umm....
Just do not use names that are "resolvable" in public IP address space or that would get you in trouble with the law for whatever reason.
just what law would that be. me thinks you're making this one up!!!!
you can call an internal machine whatever you want!! however, if you ever have a dns try to resolve the internal machine, as well as external machines.. you're going to have major issues... and if you ever try to have your dns be authoratative to the "name" that's already used by an external machine.... then yeah.. you're asking to be blasted!!!!
peace
-----Original Message----- From: centos-bounces@centos.org [mailto:centos-bounces@centos.org]On Behalf Of RobertH Sent: Monday, September 15, 2008 1:58 PM To: 'CentOS mailing list' Subject: RE: [CentOS] Changing hostname?
I'm curious - I have a local 192.168.x.x subnet inside my firewall that I would like to give a name other than just "localdomain." Does it matter what I use, or are their words/pieces I should avoid? This is strictly for my internal subnet, not visible to the outside world at all.
Thanks.
mhr
Mhr,
If what you are asking is can you setup an internal dns name to IP address and IP address to name resolution and call it what you want...
yes you can
You can call it whatever you want.
Just do not use names that are "resolvable" in public IP address space or that would get you in trouble with the law for whatever reason.
I also suggest that you read up on the mechanics of having machines you control that do both public and private dns
- rh
_______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
just what law would that be. me thinks you're making this one up!!!!
Well, let's see, I'll bet you know all this...
How about electronic identity theft at various different levels?
If you are a really big ISP, you could do a DNS denial of service by making your nameservers authoritative for a domain or domains you do not own and when it is found out go
Oops, our bad. Did we make a typo in our dns?
Can do same thing with BGP4...
How about setup systems to spoof domains and spam from them?
Etc snore ad nausem
- rh
and just how does what you describe deal with a personal network behind someone's firewall...
go back and re-read what i typed!!! i was basicaly saying there's no law that prevents you from calling the machines behind your firewall whatever you want. but that if you try to put dns servers on the public net, that try to resolve already used names to your machine (or someone else's) then you're going to get blasted...
so, i still say, where's this law for private networks???
-----Original Message----- From: centos-bounces@centos.org [mailto:centos-bounces@centos.org]On Behalf Of RobertH Sent: Monday, September 15, 2008 5:40 PM To: 'CentOS mailing list' Subject: RE: [CentOS] Changing hostname?
just what law would that be. me thinks you're making this one up!!!!
Well, let's see, I'll bet you know all this...
How about electronic identity theft at various different levels?
If you are a really big ISP, you could do a DNS denial of service by making your nameservers authoritative for a domain or domains you do not own and when it is found out go
Oops, our bad. Did we make a typo in our dns?
Can do same thing with BGP4...
How about setup systems to spoof domains and spam from them?
Etc snore ad nausem
- rh
_______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
so, i still say, where's this law for private networks???
BRUCE
I don't need to re-read your posts. Once is more than enough.
Well, that law is the law of common sense
:-)
Then one would not look like as big a moron when their mistakes becomes public.
If you look at my post, which was before yours, I mentioned that a person should read / study up on configuring and using their DNS when it involves public and private ip space.
- rh
It's worth checking that /etc/sysconfig/network also has whatever hostname you wish to use configured in it.
To effect changes, it may be necessary to restart the network:
service network restart
Mick
Niki Kovacs wrote:
Marcus Moeller a écrit :
It should look like this:
127.0.0.1 localhost.localdomain localhost calimero.local calimero
I slightly altered it:
[kikinovak@calimero ~]$ cat /etc/hosts # Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 calimero.local calimero localhost.localdomain localhost
[kikinovak@calimero ~]$ hostname calimero.local [kikinovak@calimero ~]$ hostname --fqdn calimero.local
Wouldn't this be more correct? _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
admin wrote:
It's worth checking that /etc/sysconfig/network also has whatever hostname you wish to use configured in it.
To effect changes, it may be necessary to restart the network:
service network restart
no need to restart, just run the hostname command to set your system hostname.
mouss wrote:
admin wrote:
It's worth checking that /etc/sysconfig/network also has whatever hostname you wish to use configured in it.
To effect changes, it may be necessary to restart the network:
service network restart
no need to restart, just run the hostname command to set your system hostname.
caveat though: the hostname command won't affect already running services if they rely on the hostname.
On Sat, Sep 13, 2008 at 8:42 AM, mouss mouss@netoyen.net wrote:
mouss wrote:
admin wrote:
service network restart
no need to restart, just run the hostname command to set your system hostname.
caveat though: the hostname command won't affect already running services if they rely on the hostname.
Would this do?
echo newname > /proc/sys/kernel/hostname
Akemi
[kikinovak@calimero ~]$ cat /etc/hosts
127.0.0.1 calimero.local calimero localhost.localdomain localhost
[kikinovak@calimero ~]$ hostname calimero.local [kikinovak@calimero ~]$ hostname --fqdn calimero.local
Wouldn't this be more correct?
I would suggest not making 'local' part of your server name. Although localhost.localdomain, in a non network setting, can work absolutely fine, there is an issue with your email headers. The use of locahost, local, and stuff like that is a big red flag.
I changed, in my centos 5 server, where the host name was localhost.locadomain...
/etc/sysconfig/network Hostname=server1.mydomain.com (where the domain is one of my websites on the server, actually my name server too)
Change, for sendmail to work with it, the file local-hosts-names Add the new name to it Server1.mydomain.com
Change /etc/hosts First of all, leave all the original stuff and do not alter. Underneath the original stuff, just add <ipaddress> server1.mydomain.com
REBOOT
Then do this...
shell prompt> uname -n server1.mydomain.com
shell prompt> hostname -s Server1
shell prompt> hostname -d Mydomain.com
shell prompt> hostname -f server1.mydomain.com
shell prompt> hostname server1.mydomain.com
All of these steps allows the mail headers, at least in sendmail, to function properly. Other than that, unless you are in a network, or if you are not sending mail, it is usually not a biggie if you miss some steps.
This is what I did to resolve a new hostname.
Dear Bob.
/etc/sysconfig/network Hostname=server1.mydomain.com (where the domain is one of my websites on the server, actually my name server too)
As mentioned before, I cannot see that this variable is used in any form.
Change /etc/hosts First of all, leave all the original stuff and do not alter. Underneath the original stuff, just add <ipaddress> server1.mydomain.com
REBOOT
If you have read the initial posting this is about setting up the hostname on machines without a network connection (but loopback).
Best Regards Marcus
on 9-14-2008 12:06 AM Marcus Moeller spake the following:
Dear Bob.
/etc/sysconfig/network Hostname=server1.mydomain.com (where the domain is one of my websites on the server, actually my name server too)
As mentioned before, I cannot see that this variable is used in any form.
Change /etc/hosts First of all, leave all the original stuff and do not alter. Underneath the original stuff, just add <ipaddress> server1.mydomain.com
REBOOT
If you have read the initial posting this is about setting up the hostname on machines without a network connection (but loopback).
Best Regards Marcus
Why does a system that doesn't have any way to communicate with any other machine even need a hostname?
Why does a system that doesn't have any way to communicate with any other machine even need a hostname?
It does not, but looks cool when you shell in.. Other than for email, or I guess for networking, I see no reason for it either. Mine was fine at localhost.localdomain until CBL blacklisted me because of localhost.localdomain as part of the headers. Forced a change.
But it is always good to know how to do this stuff.
127.0.0.1 localhost.localdomain localhost calimero.local calimero
Best Regards Marcus
Marcus,
Per "man hostname"
FILES /etc/hosts /etc/sysconfig/network
NOTE Note that hostname doesnât change anything permanently. After reboot original names from /etc/hosts are used again.
:-)
Do you really think one should tie the hostname to the loopback interface in the /etc/hosts file
We recommend that one should not tie the actual hostname or FQDN to the loopback interface.
There are very few limited implementation or security seclusion cases where you would want to consider doing that
It should look like this as example in /etc/hosts
127.0.0.1 localhost.localdomain localhost calimero.local
x.y.z.a calimero.some123domain.com calimero
if the machine is not talking to another machine via network, then the hostname doesnt really matter too much now does it?
Put a sticker on it.
;-)
Production server examples can be provided if you are having major issues.
- rh
Dear Robert.
Per "man hostname"
FILES /etc/hosts /etc/sysconfig/network
NOTE Note that hostname doesnât change anything permanently. After reboot original names from /etc/hosts are used again.
That's clear.
Do you really think one should tie the hostname to the loopback interface in the /etc/hosts file
If it's not necessary to set the hostname on the loopback interface, don't do so.
We recommend that one should not tie the actual hostname or FQDN to the loopback interface.
There are very few limited implementation or security seclusion cases where you would want to consider doing that
I have mentioned Arnt's statement on that.
It should look like this as example in /etc/hosts
127.0.0.1 localhost.localdomain localhost calimero.local
^^ -> should be: 127.0.0.1 localhost.localdomain localhost I guess.
or even: 127.0.0.1 localhost localhost.localdomain (see discussion on the Debian ML)
x.y.z.a calimero.some123domain.com calimero
if the machine is not talking to another machine via network, then the hostname doesn't really matter too much now does it?
No, it does not. For me it's just nice to see on which host I am working (even if it's local only).
Btw. Most major distributions set the hostname on the loopback interface and even old-style distributions like Slackware do so (with an advice) now.
But I agree, if you do not really need it, don't change 127.0.0.1 from localhost and either define the hostname on a static interface or DHCP assigned (or put a sticker on it ;).
Best Regards Marcus
Marcus,
Exactly, I have often wondered upstream does it that way so that I always have to go fix the /etc/hosts file after every CentOS install.
Since functionally, it is wrong.
- rh
RobertH wrote:
Marcus,
Exactly, I have often wondered upstream does it that way so that I always have to go fix the /etc/hosts file after every CentOS install.
Since functionally, it is wrong.
indeed, having the hostname bound to the loopback interface seems to break a bunch of our java stuff too. first thing we've always had to do after a CentOS/RHEL install is change /etc/hosts, and put the hostname on its own line with the static IP, or leave it out entirely.
John R Pierce wrote: indeed, having the hostname bound to the loopback interface seems to break a bunch of our java stuff too. first thing we've always had to do after a CentOS/RHEL install is change /etc/hosts, and put the hostname on its own line with the static IP, or leave it out entirely.
John,
Hit that nail on the head and exactly what I was describing.
Thing is, why does upstream and/or other distros do that?
What is the reasoning?
We should understand it if there is such a thing yet it appears many of us change it regardless.
I do know a several people that are not aware of it when they do installs... and I have to remind or fix.
- rh
Good Evening.
Hit that nail on the head and exactly what I was describing.
Thing is, why does upstream and/or other distros do that?
What is the reasoning?
The reason for setting a hostname on loopback is simple. Major distributions want to brand their installs even if the box has not network interface configured.
Best Regards Marcus
On Sat, 13 Sep 2008, John R Pierce wrote:
RobertH wrote:
Marcus,
Exactly, I have often wondered upstream does it that way so that I always have to go fix the /etc/hosts file after every CentOS install.
Since functionally, it is wrong.
indeed, having the hostname bound to the loopback interface seems to break a bunch of our java stuff too. first thing we've always had to do after a CentOS/RHEL install is change /etc/hosts, and put the hostname on its own line with the static IP, or leave it out entirely.
To some extent this confusion on how host names are determined, is an artifact being expressed due to the host being in a environment without the reverse DNS entries lookup working properly, or being built at one address and deployed to another with static networking. (sometimes the result gets saved into: /etc/sysconfig/network by anaconda -- by hand editing /etc/hosts, one is 'cacheing' an answer there ;) )
The 'dance' of hostname setting makes a series of inquiries, until it hits a 'success' state. By editting /etc/hosts, one is permitting it to find an answer that is 'less good' than the rDNS, but still good enough. Ditto editting /etc/sysconfig/network as the documentation in: rpm -qd initscripts describes.
This has not changed in years, but is not as well documented as it might be, as this thread reveals.
-- Russ herrold
Niki Kovacs wrote:
I recently made a CentOS install on a machine with an unsupported network card. I had to add the driver for it later, once I finished the install. For now I have this:
See http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html and look at the section titled "Changing the host name:"
Josh Donovan a écrit :
See http://www.yolinux.com/TUTORIALS/LinuxTutorialNetworking.html and look at the section titled "Changing the host name:"
Conclusion of this thread: looks like there are two different schools for configuring the hostname.
on 9-12-2008 11:06 PM Niki Kovacs spake the following:
Hi,
I recently made a CentOS install on a machine with an unsupported network card. I had to add the driver for it later, once I finished the install. For now I have this:
[kikinovak@localhost ~]$ hostname --fqdn localhost.localdomain
Q: how would I change this to something like calimero.local?
Here's what I *would* do, but I prefer to ask before.
- edit /etc/sysconfig/network and edit this line:
HOSTNAME=calimero.local
- add a line to /etc/hosts like this:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 127.0.0.1 calimero.local calimero
This should be the ip address of your local adapter, not 127.0.0.1
::1 localhost6.localdomain6 localhost6
Please correct me if I'm wrong.
cheers,
Niki Kovacs
Everything else seems OK.
On Sat, Sep 13, 2008 at 08:06:46AM +0200, Niki Kovacs wrote:
I recently made a CentOS install on a machine with an unsupported network card. I had to add the driver for it later, once I finished the install. For now I have this:
[kikinovak@localhost ~]$ hostname --fqdn localhost.localdomain
Q: how would I change this to something like calimero.local?
Here's what I *would* do, but I prefer to ask before.
- edit /etc/sysconfig/network and edit this line:
HOSTNAME=calimero.local
- add a line to /etc/hosts like this:
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 127.0.0.1 calimero.local calimero ::1 localhost6.localdomain6 localhost6
Please correct me if I'm wrong.
Lots of replies to this already. The critical thing to understand is that it is the network interfaces that have names not the box.
Sendmail and some other tools look for host names that have at least one dot in them. Thus localhost.localdomain gets paired with localhost as a CNAME.
This line: 127.0.0.1 localhost.localdomain localhost associated the ipaddress 127.0.0.1 with the name localhost.localdomain and its CNAME/ alias localhost.
This second line is interesting 127.0.0.1 calimero.local calimero It appears to redefine the relationship with 127.0.0.1 If you were programing and had two lines foo="this" foo="that" You would expect the second assignment for foo to win and the second to be lost. It is possible that the pair of lines acts a bit like a =+ assignment I would have to check.
A better line would be 127.0.0.1 localhost.localdomain calimero.local calimero or perhaps... 127.0.0.1 localhost.localdomain calimero.localdomain calimero
These make it clear that you want all four names (long and short) associated with 127.0.0.1
Having HOSTNAME set in places like /etc/sysconfig/network with a line like: HOSTNAME=calimero has advantages in lots of ways... with wireless and other dynamic situations where plugging a wire in or wired connection to hot spots and more are possible keeping the 'hostname' handy makes sense for a handful of reasons. Link local zeroconfig .... It also permits the host to have the 'short' CNAME of calimero and still discover its fully qualified (lots of dots) host name.
One advantage of caching the name of the host permits the like of dynamic DNS to work.... and lots more like on line off line operation for mail composition and more.
In the case of swapping out the network card you need to look at /etc/sysconfig/network.scripts and /etc/modprobe.conf with a multiple network card admin hat on. It may be as simple as removing the old network interface (old hardware) and adding a new one with the same name. The graphical tools may make this way easy...
In the system and in the internet there are commonly aliases for things. For example eth0 is the common alias (sometimes defined in /etc/modprobe.conf) for ethernet ports. See also /etc/sysconfig/network-scripts/ifcfg-eth0 for lines like "DEVICE=eth0" Aliases permit lots of layers of scripts to run without knowing the specific driver name.
If you reflect back on your initial install, you were asked if the host name was obtained from DHCP or was set (known) locally. So "it depends"... on decisions you made and also external decisions.
Dear Tom.
# Do not remove the following line, or various programs # that require network functionality will fail. 127.0.0.1 localhost.localdomain localhost 127.0.0.1 calimero.local calimero ::1 localhost6.localdomain6 localhost6
Lots of replies to this already. The critical thing to understand is that it is the network interfaces that have names not the box.
Sendmail and some other tools look for host names that have at least one dot in them. Thus localhost.localdomain gets paired with localhost as a CNAME.
I would suggest to use localhost localhost.localdomain (if it's really required) instead. 127.0.0.1 should resolve to localhost only (as mentioned before).
A better line would be 127.0.0.1 localhost.localdomain calimero.local calimero or perhaps... 127.0.0.1 localhost.localdomain calimero.localdomain calimero
These make it clear that you want all four names (long and short) associated with 127.0.0.1
See above. Please do not add hostnames other than localhost to 127.0.0.1. Add the hostname to your network interface, instead.
Having HOSTNAME set in places like /etc/sysconfig/network with a line like: HOSTNAME=calimero has advantages in lots of ways... with wireless and other dynamic situations where plugging a wire in or wired connection to hot spots and more are possible keeping the 'hostname' handy makes sense for a handful of reasons. Link local zeroconfig .... It also permits the host to have the 'short' CNAME of calimero and still discover its fully qualified (lots of dots) host name.
If you just set HOSTNAME in /etc/sysconfig/network the hostname is set during boot but is not resolvable. Therefore you should make sure that /etc/hosts and HOSTNAME are set. The last one is optional (see ifup-post in previous postings) but good-style.
Best Regards Marcus