Control theory is used to determine optimal disturbances in pipe flow and the forcing, in the form of blowing and suction at the wall, capable of attenuating them. An approach is adopted, based on a parabolic approximation of the linear Navier–Stokes equations, which is appropriate when dealing with asymptotically elongated (in the streamwise direction) flow structures. A cost functional is introduced and maximized in the optimal-perturbation problem or minimized, for a given inflow perturbation, in the optimal-control problem. The extrema of the cost functional are reached by means of an iterative technique, based on the numerical solution of the equations for the state and the adjoint state, coupled via transfer and optimality conditions. Central to the control is the determination of the Green's function expressing the receptivity of the flow to wall forcing. A considerable reduction in output disturbance energy, as compared to the uncontrolled case, is obtained for control laws operating both over a long section of the pipe or over shorter strips. Finally, a robust control is sought, by simultaneously computing the worst inflow condition and the corresponding best control at the wall.