Reconfigure network configs after OS cloning / mainboard replacement  (RH 5/6)

 

for e in eth0=eth2 eth1=eth3 eth2=eth4 eth3=eth5 eth4=eth0 eth5=eth1;do
   mac=$(ifconfig $(echo $e | awk -F= '{print $1}') | grep -oP "..:..:..:..:..:..")
   sed -i "s/..:..:..:..:..:../$mac/g" /etc/sysconfig/network-scripts/ifcfg-$(echo $e | awk -F= '{print $2}')
done