in reply to extracting variables from regex
printf "%X%X%X%X\n",$1,$2,$3,$4
Is going to cause you (or someone downstream of you who happens to have a different IP address) no end of grief. I think you'll be happier with
printf "%02X%02X%02X%02X\n",$1,$2,$3,$4