Putting site into maintenance mode while developing

How can I put my site into maintenance mode while I'm developing? And once it's on, how would I be able to view the site for testing?