Wild animals are protective of their young and will defend themselves if they feel threatened, or provoked such as being chased by a dog. Keep your dog on a leash at all times. Contrary to popular belief, these attacks are not limited to the nighttime hours and are not limited to small pets. Keeping dogs in a fenced or walled area is desirable for this reason, although a small pet that is enclosed in a yard may still be vulnerable to predators who can fly. Cats are much safer indoors.
Neutered pets are less likely to run away, making themselves vulnerable.
Keep pets far away from the snake. Rattlesnakes can lunge up to one half their body length. Install hardware cloth where you have gaps or openings in your fence and under gates to help keep snakes out. Snakes often end up in garages, so keeping the garage door shut may help keep them out. If you or your pet is bitten by a snake seek medical help immediately.