The gun turret dynamic model and state-space model of barrel elastic deformation are established aiming at the issue that gun barrel vibration affects firing accuracy. Based on this system model, the nonlinear state-feedback controller and nonlinear state observer are designed by means of sum of squares(SOS). Conditions compatible with the separation principle for the controller and observer are given. The result of numerical simulation shows that this method performs effective restraint on gun barrel vibration as the gun following system drives the turret.