Optimal control and shape optimization techniques have an increasing role in Fluid Dynamics problems governed by Partial Differential Equations (PDEs). In this paper we consider the problem of drag minimization for a body in relative motion in a fluid by controlling the velocity through the body boundary. With this aim we handle with an optimal control approach applied to the steady incompressible Navier–Stokes equations. We use the Lagrangian functional approach and we adopt the Lagrangian multiplier method for the treatment of the Dirichlet boundary conditions, which include the control function itself. Moreover we express the drag coefficient, which is the functional to be minimized, through the variational form of the Navier–Stokes equations. In this way we can derive, in a straightforward manner, the adjoint and sensitivity equations associated with the optimal control problem, even in presence of Dirichlet control functions. The problem is solved numerically by an iterative optimization procedure applied to state and adjoint PDEs which we approximate by the finite element method.