Changing hostname in /etc/hosts so that it is defined to ip-address and not loopback
Hi!
I'm really clueless. I have to configure two network interface cards. I want to change the /etc/hosts file so that the hostname is defined to my ip-address and not to the loopback device. In the following extract (I put in line numbers to make it easier) I am confused as to where I should type in my specific details:
****************************************
1 ip_address=`/bin/hostname -i`
2 host_name=`/bin/hostname -f`
3 short_name=`/bin/hostname -s`
4 sed -i "s/127.0.0.1.*/127.0.0.1 localhost.localdomain localhost/g" /etc/hosts
5 sed -i "s/$ip_address/#$ip_address/g" /etc/hosts
6 echo "$ip_address $host_name $short_name" >> /etc/hosts
*****************************************
Question 1)
Do I put my computer's hostname at the /bin/hostname part in line 1, or do I put it at host_name in line 2 ?
For example, if my hostname is gnlserv01, and the ip-address for the private interface is 192.168.1.254 would I type the following into a terminal for line 1:
ip_address = `/bin/gnlserv01 -i`
or
192.168.1.254 = `/bin/hostname -i`
or something else?
Question 2)
Why do I need a short_name, and can I make it anything I want?
It doesn't seem as if it reverts to the loopback device if I do the following:
************************************
[root@gnlserv01 ~]# /bin/hostname
gnlserv01
[root@gnlserv01 ~]# ping -c1 gnlserv01
PING gnlserv01.getec (192.168.1.254) 56(84) bytes of data.
64 bytes from gnlserv01.getec (192.168.1.254): icmp_seq=1 ttl=64 time=0.025 ms
--- gnlserv01.getec ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.025/0.025/0.025/0.000 ms
**************************************
This is what is in my /etc/hosts at present:
************************************
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
192.168.1.254 gnlserv01.getec gnlserv01
::1 localhost.localdomain localhost gnlserv01
************************************
Question 3)
My public interface is configured (hm, that's how I get on the internet), should it be seen in the /etc/hosts or not?
|