Use galvanized nails, as these will not rust. Birdhouses need not be painted, but the box may last longer if you paint the outside. Never paint the inside of a birdhouse. If you paint the outside, use dull (not bright or glossy) colors that blend in with the surroundings. Nest boxes that don't match the vegetation may be easier for predators to find.
Train outdoor pets to keep away from bird houses: Behavioral conditioning with a water hose is an effective method that can also be used on squirrels and other wildlife with enough patience and perseverance. Pets should be supervised when outdoors during the nesting season as well, since young birds leave the nest several days before they can fly, making them easy targets for curious pets. Be sure the bird house opening is the right size for the species you wish to attract: If the opening is too large, predators will have easy access to the nest and other bird species may take over. A very large opening may also be dangerous for growing chicks, which could tumble out of the hole. A small hole could cause birds to get stuck, or they won't use the house at all.