Friday, February 15, 2008

How to set the Linux Host Name?

นานๆเปลี่ยนที เลยลืม command อ่ะ -*-

Step 1 : ตรวจสอบ host name ก่อน
using the following commands: หลายแบบ
#uname -n
#hostname -a
#hostname -s
#hostname -d
#hostname -f
#hostname

Step 2 : กำหนด hosts ใน /etc/hosts
ถ้าใช้ IP address ที่แจกให้โดย DHCP server, ใน/etc/hosts ให้ใส่ค่าตามนี้:

127.0.0.1 leokit.blogspot.com localhost.localdomain localhost leokit

ถ้าใช้ static IP address , ใน/etc/hosts ให้ใส่ค่าตามนี้:

127.0.0.1 localhost.localdomain localhost
192.168.0.1 leokit.blogspot.com leokit


Step 3 : Setting the Host Name using "hostname"
หลังจากแก้ไขใน hosts ไฟล์แล้ว ให้เรา run คำสั่งนี้
#hostname leokit.blogspot.com
Step 4 : ตรวจสอบ ใน /etc/HOSTNAME
leokit.blogspot.com
Step 5 : ตรวจสอบ ใน /etc/sysconfig/network
ถ้าใช้ static IP address , ใน/etc/sysconfig/network ให้ใส่ค่าตามนี้:
NETWORKING=yes
HOSTNAME="leokit.blogspot.com"

Step 6 : ตรวจสอบ ใน /proc/sys/kernael/hostname
ตรวจสอบโดยใช้ command
#cat /proc/sys/kernel/hostname

หลังจาก Set แล้วให้ทำการ reboot หรือจะ run คำสั่งนี้ก็ได้นะ
echo leokit.blogspot.com > /proc/sys/kernel/hostname

No comments: