Input validation for ip address