Corrosion is a redox reaction in which a pure metal reacts with substances in the environment, returning to an ore-like state. Aluminum, for example, rapidly oxidizes in air:
4 Al(s) + 3 O2(g) → 2 Al2O3(s).
This the surface of the Al(s) in a thin layer of Al2O3(s), preventing any further corrosion on the inside—oxygen cannot get past the aluminum oxide to corrode the pure aluminum.
When iron corrodes, the rust flakes off and exposes new iron. This requires the presence of both oxygen and water. It is accelerated by acidic solutions, electrolytes, mechanical stress, and contact with less active metals. There are multiple steps in the rusting process:
The iron oxidation occurs at one location (anode) and the oxygen reduction occurs at another (cathode). The rust piles up between them. Eliminating either water or oxygen makes this rusting process impossible.
There are two methods for preventing corrosion. Protective coating is just what it sounds like: cover up the surface to prevent it from coming in contact with oxidizing agents. Cathodic protection works by supplying the iron with an electric current, forcing the metal to become the cathode and making corrosion non-spontaneous. You can combine both methods using a sacrificial anode, where you coat the surface with a more active metal. This protects the surface and it forces the other metal to be the cathode. Zinc plating, also known as galvanizing, is an example of this.