Oracle Corp. said Monday that it would buy web-service provider Dyn, a company that came into the public eye after it was hit by a large-scale internet attack in October that left dozens of popular websites unreachable for parts of the day.

Dyn, based in New Hampshire, is among a handful of companies operating domain-name systems that help direct traffic across the internet. Dyn’s services are crucial cogs in helping internet users reach websites by allowing web addresses—Netflix.com, for instance—to take users to their final...