linux��hostname������
����Linux����ϵͳ��hostname��һ��kernel����������ͨ��hostname�������鿴������hostname��Ҳ����ֱ��cat /proc/sys/kernel/hostname�鿴��
����#hostname
����#cat /proc/sys/kernel/hostname
����������������������ͬ��
����������ʱLinuxϵͳ��hostname��������Ҫ����ϵͳ
����hostname������������ϵͳ��hostname
����#hostname newname
����newname��Ҫ���õ��µ�hostname�����к�������Ч��������ϵͳ�������ᶪʧ�������ģ�����Ҫ���ø���ϵͳ��hostname����Ҫ�����ص������ļ���
�������ø���Linux��hostname
����man hostname������ôһ�仰��”The host name is usually set once at system startup in /etc/rc.d/rc.inet1 or /etc/init.d/boot (normally by reading the contents of a file which contains the host name, e.g. /etc/hostname).” RedHat��û�������ļ���������/etc/rc.d/rc.sysinit�����ű���������ϵͳ��hostname������ȡ/etc /sysconfig/network�����ı��ļ���RedHat��hostname�����������ļ������á�
�������ԣ�����Ҫ������RedHat��hostname������/etc/sysconfig/network�ļ�����������HOSTNAME��һ���ij�HOSTNAME=NEWNAME������NEWNAME������Ҫ���õ�hostname��
����Debian���а���hostname�������ļ���/etc/hostname��
�����������ļ���������ϵͳ�ͻ���ȡ�����ļ������µ�hostname��
����hostname��/etc/hosts�Ĺ�ϵ
�����ܹ���һ�ᵽ����hostname���Ⱦ��뵽��/etc/hosts�ļ�����Ϊhostname�������ļ�����/etc/hosts����ʵ���ǵġ�
����hosts�ļ��������൱��DNS���ṩIP��ַ��hostname�Ķ�Ӧ�����ڵĻ������������٣�����hosts�ļ����㹻���������������������������Ż������ķ�չ������ԶԶ�����ˡ����Ǿͳ����˷ֲ�ʽ��DNSϵͳ����DNS���������ṩ���Ƶ�IP��ַ�������Ķ�Ӧ����������man hosts��
����Linuxϵͳ����DNS����������������������֮ǰ����ѯ/etc/hosts�ļ���������������Ӧ�ļ�¼���ͻ�ʹ��hosts�����ļ�¼��/etc/hosts�ļ�ͨ������������һ����¼
����127.0.0.1 localhost.localdomain localhost
����hosts�ļ���ʽ��һ��һ����¼���ֱ���IP��ַ hostname aliases�������ÿհ��ַ��ָ���aliases��ѡ��
����127.0.0.1��localhost��һ�����鲻Ҫ�ģ���Ϊ�ܶ�Ӧ�ó������õ�����������sendmail����֮����Щ�������ܾ����������С�
������hostname����������Ҫ�ڱ�������newhostname�����ʣ��ͱ�����/etc/hosts�ļ�������һ��newhostname�ļ�¼�������ҵ�eth0��IP��192.168.1.61���ҽ�hosts�ļ������£�
����#hostname blog.infernor.net
����# cat /etc/hosts
����127.0.0.1 localhost.localdomain localhost
����192.168.1.61 blog.infernor.net blog
�����������ҾͿ���ͨ��blog����blog.infernor.net�����ʱ�����
������������Щ������/etc/hosts������hostname��ûֱ�ӹ�ϵ�ģ���������Ҫ�ڱ��������µ�hostname�������Լ���ʱ���Ż��õ�/etc/hosts�ļ�������û�б�Ȼ����ϵ��
����RHEL���и����⡣
�����ҿ�ʼ�ڲ��Ե�ʱ����ֻ��/etc/hosts���������� 192.168.1.61 blog.infernor.net blog����/etc/sysconfig/networkά��ԭ״��Ҳ����������HOSTNAME=localhost.localdomain��������ϵͳ����Ȼ����hostname���ij���blog.infernor.net���������Ļ�����������/etc/hosts��hostname�������ļ�������������/etc/rc.d/rc.sysinit���������ű���������������ڡ�
����rc.sysinit�ļ���һ��ʼ��������hostname
����if [ -f /etc/sysconfig/network ]; then
����. /etc/sysconfig/network
����fi
����if [ -z "$HOSTNAME" -o "$HOSTNAME" = "(none)" ]; then
����HOSTNAME=localhost
����fi
����ȷʵʹ����/etc/sysconfig/network����hostnameֵ���������滹��һ�ι�������hostname��
����ipaddr=
����if [ "$HOSTNAME" = "localhost" -o "$HOSTNAME" = "localhost.localdomain" ]
����; then
����ipaddr=$(ip addr show to 0/0 scope global | awk '/[[:space:]]inet
����/ { print gensub("/.*","","g",$2) }')
����if [ -n "$ipaddr" ]; then
����eval $(ipcalc -h $ipaddr 2>/dev/null)
����hostname ${HOSTNAME}
����fi
����fi
�����ű��ж�hostname�Ƿ�Ϊlocalhost����localhost.localdomain�������ǵĻ�������ʹ�ýӿ�IP��ַ��Ӧ�� hostname����������ϵͳ��hostname�������ͳ�������ҵ�/etc/sysconfig/networkĬ�ϵ�hostname�� localhost.localdomain��eth0��IP��192.168.1.61����/etc/hosts����192.168.1.61�ļ�¼�����Ǿ���192.168.1.61������¼���滻��hostname��
����������Ҳ�Ǻܶ��˽�/etc/hosts����Ϊ��hostname�������ļ���ԭ����
����hostname��ѡ����ѯ
����hostname��-s -f -i�ȵ�ѡ��õ���/etc/hosts����DNSϵͳ�����������۵�hostname�е�Զ�ˣ�Ҳ���ײ������ᡣ��������man hostname�鿴��
- ת����ע����Դ��ITѧϰ�� ��ַ��http://www.t086.com/ �����������Ƽ�������
- �ر������� ��վ�������ر�������ֹת�ص�ר�������������¿�������ת�أ���������ע��������ԭʼ���ߡ����°�Ȩ������ԭʼ�������С����ڱ���վת�����µĸ��˺���վ�����DZ�ʾ������л�⡣������վת�ص������а�Ȩ��������ϵ���ǣ����ǻᾡ�����Ը�����