From e64f3d3dd72622d32e588acd0777798f867eba8f Mon Sep 17 00:00:00 2001 From: junxiawang Date: Fri, 22 May 2015 06:54:55 -0400 Subject: [PATCH] fix bug 4565 --- xCAT/postscripts/configeth | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/xCAT/postscripts/configeth b/xCAT/postscripts/configeth index 590a78598..12883aefe 100755 --- a/xCAT/postscripts/configeth +++ b/xCAT/postscripts/configeth @@ -524,6 +524,22 @@ elif [ "$1" = "-s" ];then str_inst_ip=`grep IPADDR $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"` str_inst_mask=`grep NETMASK $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"` str_inst_gateway=`grep GATEWAYS $str_lease_file | tail -n 1 | awk -F'=' '{print $2}' | sed "s/'//g"` + else + if [ -n "$MACADDRESS" ];then + str_inst_mac=$MACADDRESS + inst_nic=`ip -o link |grep -i ${str_inst_mac} |awk '{print $2}'|sed 's/://g'` + if [ ! -z "${inst_nic}" ];then + str_inst_ip=`ip -4 -o addr|grep -i ${inst_nic} |awk '{print $4}'|awk -F/ '{print $1}'` + if [ ! -z "str_inst_ip" ];then + inst_ip_pre=`ip ro ls|grep -i ${str_inst_ip}|awk '{print $1}'|awk -F/ '{print $1}'` + if [ ! -z "inst_ip_pre" ];then + str_inst_mask=`route |grep ${inst_ip_pre}|awk '{print $3}'|head -1` + fi + fi + fi + str_inst_gateway=`ip ro ls|grep default|awk '{print $3}'|head -1` + echo "str_inst_gateway is $str_inst_gateway" + fi fi else str_lease_file=`ls /var/lib/dhclient/*$str_inst_nic* | grep leases`