In general, dogs know that snakes can be threats and will not hesitate to intervene to protect their loved ones.
Several cases are well known, but a particularly striking example is that of Haus, a German Shepherd that risked his life to save a 7-year-old girl in Florida. The little girl and her faithful protector came face to face with a dangerous rattlesnake in the backyard of the family residence in Tampa. Haus quickly stepped between the snake and the girl, getting his leg bitten three times.
The little girl escaped unharmed, and the German Shepherd thankfully recovered from his injuries after intensive treatment at BluePearl Specialty and Emergency Pet Hospital.