The iron rust is formed due to electrochemical reaction. Different regions on iron surface become unode and cathode.
Reaction on anode region:
Fe(s) → Fe2+ (aq) + 2e-
Reaction on cathode region:
O2(g) + 4H+ (aq) + 4e- → 2H2O(I)
when Fe2+ ions migrate from anode region they react with water to form Fe3+ ions.
A reddish coloured hydrated oxide is formed from Fe3+ ions. It is called rust.
2Fe3+ (aq) + 4H2O(I) → + Fe2O3. H2O(s) + 6H+ (aq)
A way to prevent rusting by colouring with acrylic paints, Zn plating, galvanizing, anodizing, alloying, etc.