Installing a commercial, stainless steel chimney cap over the top of the chimney is the best way to keep raccoons out of your chimney. Make sure screws are used to fasten the cap to the flue.
If a raccoon is already using your chimney, you will need to drive the animal out, then cap the chimney. Do not use fire or smoke to encourage animals to leave. You will probably kill the animal and still need to deal with removal. Here are some other more effective methods:
Wait it out
If it is spring or summer the raccoons may be a female and her young. The mother raccoon will normally move them out of the chimney when the young are weaned in a few weeks.
Repellents or frightening may be effective
Placing substances with strong smells above the damper, such as vinegar, moth flakes, raccoon eviction fluid (if a female with cubs) or commercial raccoon repellents, may be effective in evicting raccoons. You also can try frightening with a loud radio and/or lights placed near the damper or inside the chimney. These methods should be initiated around dusk, just before the raccoons' normal activity period.
Trapping can also be considered
Place and secure cage traps near the chimney or access points on the building. Bait them with fresh fruits, cat food, canned fish, or professional paste baits and lures.
Reduce access to your roof
Remove any overhanging branches from nearby trees. If raccoons are climbing up the house corner to the roof, wrap or tack the corner with sheet metal at least 3-feet square to deter climbing; although this might not be practical for some homeowners.
Go pro
Hiring a licensed, professional wildlife control operator is also an option.
Clean and cap
Once raccoons are gone, cap the chimney and clean out all nesting debris following Centers for Disease Control and Prevention (CDC) safety practices. The CDC strongly recommends you take care to avoid contaminating your hands and clothes. Wear disposable gloves to help prevent cross contamination. Wear an N95-rated respirator if working in a confined space to prevent accidental ingestion of eggs or other harmful materials. Avoid stirring up dust and debris by using a spray bottle to lightly mist the area with a little water. Wear rubber boots that can be scrubbed or cover your shoes with disposable booties so that you do not bring eggs into your living space. Material contaminated with raccoon feces should be removed and burned, buried, or sent to a landfill. Treat feces-soiled surfaces with a damp (but not wet) sponge and wipe the area with hot soapy water. Rinse the sponge frequently. After you are finished, flush dirty water down the toilet. Place the sponge in a plastic bag and put it in the garbage. Wash your hands well with soap and warm running water then take a shower and wash your hair. Clean/launder your clothes thoroughly with hot water and detergent.
You are encouraged to release trapped raccoons nearby. Female raccoons will return for their young. You can carefully capture infant raccoon cubs with gloved hands or by using a capture pole/graspers. Place the young raccoons in a cardboard box, secured outside and near the entry hole, at dusk.