Is doing an IP lookup legal?
Yes. The information regarding the IP addresses is public, so you will have no problem with the law.