The clove hitch is a good knot to use to tie a line to a pipe or post.

How to tie a clove hitch
Take the running end of the line and wrap it around the post twice, the first time the running end should end up below the standing part, the second time the running end crosses over to be above the standing part. Finish the knot by slipping the running end under the crossover and pull to tighten.

You can also form a clove hitch in the middle of the line by making to adjacent underhand loops and slipping them over the post.