We present the first cosmological constraint on dark matter scattering with protons in the early Universe for the entire range of dark matter masses between 1 keV and 1 TeV. This constraint is derived from the Planck measurements of the cosmic microwave background (CMB) temperature and polarization anisotropy, and the CMB lensing anisotropy. It improves upon previous CMB constraints by many orders of magnitude, where limits are available, and closes the gap in coverage for low-mass dark matter candidates. We focus on two canonical interaction scenarios: spin-independent and spin-dependent scattering with no velocity dependence. Our results exclude (with 95% confidence) spin-independent interactions with cross sections greater than $5.3 times 10^{-27}$ cm$^2$ for 1 keV, $3.0 times 10^{-26}$ cm$^2$ for 1 MeV, $1.7 times 10^{-25}$ cm$^2$ for 1 GeV, and $1.6 times 10^{-23}$ cm$^2$ for 1 TeV dark matter mass. Finally, we discuss the implications of this study for dark matter physics and future observations.