High penetration of Distributed Generation (DG) in Medium Voltage (MV) power grids is usually a reason of abrupt voltage raises. In this respect critical scenarios are represented by both low demand conditions and high power production from renewable sources. In order to cope with the possibly resulting voltage limits violation, a typical adopted approach is the disconnection of the distributed generators or the curtailment of the generated power leading to several disadvantages. To address this issue an online management of the reactive power of distributed generators is presented. The approach is based on Command Governor (CG) ideas and is aimed at solving a constrained voltage regulation problem in both centralized and distributed ways. The approach foresees an active coordination between some controllable devices of the grid, e.g. distributed generators, MV/HV transformers, in order to maintain relevant system variables within prescribed operative constraints in response to unexpected adverse conditions. Simulation results show that the proposed approach is more effective than approaches suggested by the current Italian norms on reactive power compensation.