I have four network card on my server, I have assigned each with an specific IP now I want to set an different
hostname for all the interface?
What is the difference between setting the
hostname in file
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
The entry in
/etc/sysconfig/network is where RHEL (and derivatives such as CentOS) set the hostname/nodename that you'll see reflected on for instance the prompt of your shell, in system and log messages etc. That is the hostname that will be returned by the
uname system calls.
A system only has one hostname/nodename, but it can have many interfaces.
You can point unlimited hostnames (or rather DNS names) to each interface, each ip-address. A many-to-one relationship.
The reverse mapping from ip-address to DNS name is one-to-one. A reverse DNS lookup (using a PTR record or the same using /etc/hosts) will only return one name.
/etc/hosts file is simply a local lookup table mapping ip-adresses to hostnames and the reverse. If you have a functional DNS server that will often be easier to maintain that rather then keeping many hosts files on different systems in sync.
Some network services will start slowly, fail and/or give warnings if they can not resolve the hostname to an ip-address. (i.e. when being started in single user mode or when DNS fails to respond) so it is not uncommon to see /etc/hosts contains a reference to the hostname as well.
/etc/hosts entry takes precedence over DNS allowing you to locally do "interesting" things.