"Validate" is a pretty vague term - do you just care if it looks right, or do you want to make sure that there actually is a machine visble out there with that particular IP?
if it's just the look of the thing,
if(preg_match('/(\d{1,3}).(\d{1,3}).(\d{1,3}).(\d{1,3})/',$ip,$match)
{
if($match[1]<256 && $match[2]<256 && $match[3]<256)
{
...looks like an IP to me...
}
}