Your domesticated dog still has a natural prey drive that encourages him to approach pretty much any small animal he comes across in his daily life. Unfortunately, if the animal that your dog has found is a porcupine, then the end result of the encounter is likely to be a painful experience you won't soon forget.
Porcupines are vegetarians; their diet primarily consists of pine trees and other forest plants. Porcupines are technically considered large rodents and the quills that cover their backs are their way of protecting themselves from being eaten by larger predators. Porcupines cannot shoot the quills on their back at a predator; the predator has to come into direct contact with the quills in order to get stuck by the porcupine. Porcupines grow new quills to replace the ones that they lost when your dog decided to investigate them.
Porcupines are nocturnal and are rarely encountered during the day. If you want to protect your dog from a porcupine, your best bet is to keep him inside your home or in a fenced in, enclosed area during the nighttime hours. If you are taking a walk in an area where you believe you may encounter a porcupine, keep your dog on a leash so he cannot approach the porcupine.
Dogs and Quills
Porcupine quills have sharp ends that get stuck in your dog's skin when he attempts to investigate or play with the porcupine. Porcupine quills need to be removed by a veterinarian immediately after your dog gets stuck with them because the quills will be pushed deeper into the skin as your dog tries to get them out on his own. Quills that break off inside your dog's body can migrate to other parts of his body, causing serious internal injury or even death.
Your veterinarian will need to sedate your dog and then extract each quill individually by hand. There is no shortcut for getting porcupine quills back out of your dog's skin. Once the quills are removed, you still have to treat each individual quill wound as a unique injury and watch your dog carefully for infection. Dogs rarely learn to avoid porcupines based on a single encounter and many dogs become repeat offenders.