The rising share of renewable energy sources in electricity grids has strongly impacted the operation of both transmission and distribution systems. With the decommissioning of synchronous generators, the transmission systems are becoming less resilient to disturbances, while the proliferation of Distributed Energy Resources (DERs) in distribution networks has opened new possibilities for distribution system operators, enabling them to support the transmission system by offering ancillary services. This paper proposes a centralized controller for provision of Primary Frequency Control (PFC) by aggregations of DERs in active distribution networks. The controller aims to find optimal setpoint adjustments for DERs to regulate the power flow at the transmission system interconnection according to PFC provision requirements. At the heart of the proposed method lies a multi-period optimal power flow formulation, which accommodates different timescale dynamics of the employed DERs, as well as the network constraints. The active power required for provision of PFC is calculated using a recently developed frequency prediction model. Simulation results obtained from a dynamic model of the IEEE 33-bus system demonstrate the effectiveness of the proposed scheme.