Long-term corrosion protection of metals might be provided by nanocomposite coatings having synergistic qualities. In this perspective, rapeseed oil-based polyurethane (ROPU) and nanocomposites with calcium and magnesium ions were designed. The structure of these nanocomposites was established through Fourier-transform infrared spectroscopy (FT-IR). The morphological studies were carried out using scanning electron microscopy (SEM) as well as transmission electron microscopy (TEM). Their thermal characteristics were studied using thermogravimetric analysis (TGA). Electrochemical experiments were applied for the assessment of the corrosion inhibition performance of these coatings in 3.5 wt. % NaCl solution for 7 days. After completion of the test, the results revealed a very low icorr value of 7.73 × 10-10 A cm-2, a low corrosion rate of 8.342 × 10-5 mpy, impedance 1.0 × 107 Ω cm2, and phase angle (approx 90°). These findings demonstrated that nanocomposite coatings outperformed ordinary ROPU and other published methods in terms of anticorrosive activity. The excellent anti-corrosive characteristic of the suggested nanocomposite coatings opens up new possibilities for the creation of advanced high-performance coatings for a variety of metal industries.