The Israeli military has vowed to retaliate to a missile attack from Iran, which Iran said was a "rational and legitimate response" to previous Israeli fire.