Abstract-This paper investigates the problem of optimal frequency regulation of multi-machine power networks where each synchronous machine is described by a sixth order model. By analyzing the physical energy stored in the network and the generators, a port-Hamiltonian representation of the multimachine system is obtained. Moreover, it is shown that the openloop system is passive with respect to its steady states which implies that passive controllers can be used to control the multimachine network. As a special case, a distributed consensus based controller is designed that regulates the frequency and minimizes a global quadratic generation cost in the presence of a constant unknown demand. In addition, the proposed controller allows freedom in choosing any desired connected undirected weighted communication graph.