Sacrificial protection is the protection of iron or steel against corrosion by using a more reactive metal. Pieces of zinc or magnesium alloy are attached to pump bodies and pipes. The protected metal becomes the cathode and does not corrode. The anode corrodes, thereby providing the desired sacrificial protection. These items are known as sacrificial anodes and "attract" the corrosion to them rather than the iron/steel. The sacrificial anodes must be replaced periodically as they corrode.
The iron pipe will be connected to a more reactive metal such as magnesium through cooper wires, the magnesium will donate its electrons to the iron preventing it from rusting. Iron which is oxidises will immediately be reduced back to iron.
Generalic, Eni. "Sacrificial protection." Croatian-English Chemistry Dictionary & Glossary. 29 June 2022. KTF-Split. {Date of access}. <https://glossary.periodni.com>.
Glossary
Periodic Table