2012年12月22日 星期六

Ascii hex (IEEE754) 轉成 flaot in python

import sys
form binascii import unhexlify
s = unhexlify(sys.argv[1]) + unhexlify(sys.argv[2]) \
+ unhexlify(sys.argv[3]) + unhexlify(sys.argv[4])
import struct
result = struct.unpack_from('f', s)
print result[0]

2012年12月6日 星期四

Route setting under multi interfaces

The GATEWAY setting in ifcfg-eth0 will add a default gateway while interface starts, but may be overwrited by next started interface. To avoid this, remove the GATEWAY setting in ifcfg-eth0 and use route-eth0 file
Note. NetworkManager should be stopped

for Example, If there are two interface eth0 and eth1
ifcfg-eth0

DEVICE=eth0
IPADDR=10.3.23.221
NETMASK=255.0.0.0
#GATEWAY=10.3.23.254
ifcfg-eth1
DEVICE=eth0
IPADDR=172.18.101.2
NETMASK=255.255.0.0
#GATEWAY=172.18.254.254
route-eth0
default 10.3.23.254 dev eth0
route-eth1
172.16.0.0/12 via 172.18.254.254 dev eth1