RTNETLINK answers: File exists error when restarting network

RTNETLINK answers: File exists error happens often when we edit the network interface file with a new IP / gateway and try to bring back the interface online. Point to note is that we can’t have more than one gateway in the network interfaces. In fact, we cannot have same default gateway on different interface or more than one gateway in one interface. If we try to add like above and restart the interface using ifup/ifdown or service restart, it will show errors like as below
RTNETLINK answers: File exists
Failed to bring up eth0
In the above error, the network interface is eth0
This is because of some sort of mismatch in the caching the OS uses for the active network connections. To solve this, we need to flush it before we issue an ifup/ifdown or a network restart. Running the below command will usually fix this.
# sudo ip addr flush dev eth0
or we can ignore the errors/warning when bringing the interface online
# sudo ifup –ignore-errors eth0
After running the above commands, you should be able to issue ifup/ifdown commands or restart the network service.