  We derive the anomaly polynomials of 4d $\mathcal{N}=2$ theories that are
obtained by wrapping M5-branes on a Riemann surface with arbitrary regular
punctures, using anomaly inflow in the corresponding M-theory setup. Our
results match the known anomaly polynomials for the 4d $\mathcal{N}=2$ class
$\mathcal{S}$ SCFTs. In our approach, the contributions to the 't Hooft
anomalies due to boundary conditions at the punctures are determined entirely
by $G_4$-flux in the 11d geometry. This computation provides a top-down
derivation of these contributions that utilizes the geometric definition of the
field theories, complementing the previous field-theoretic arguments.
