Rusting of iron can be prevented by the following two ways:
By coating the surface of iron with paint: On coating, air and moisture cannot come in contact with iron and hence, no rusting takes place.
By applying grease or oil on the surface of iron: This method also prevents air and moisture to come in contact with iron and hence, no rusting takes place.