Linux hostid

| | Comments (0)

Linux 的 hostid 的算法是用 $HOSTNAME 反查, 得到 IP, IP 四個數字轉 Hex, 再做 2143 順位的轉換
例如: IP 是 192.168.0.1
轉 Hex 是 c0a80001, 再做 2143 順位轉換得 a8c00100
下面這段 script 相當於取 hostid
IP=`gethostip $HOSTNAME | awk '{print $NF}'`
echo ${IP:2:2}${IP:0:2}${IP:6:2}${IP:4:2}

Leave a comment

March 2009

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

About this Entry

This page contains a single entry by Pank published on October 7, 2005 3:53 PM.

NET2COM was the previous entry in this blog.

FreeBSD mount USB storage is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.