Linux 101 : Troubleshooting double IP address assignment - error - RTNETLINK answers: Cannot assign requested address



Sometimes, we mistakenly assign two addresses to an interface, one dynamic and one static for example.
We get the below results when we check the interface:


When we try to delete one of IP addresses using:


We get the below error:

RTNETLINK answers: Cannot assign requested address

One solution is to flush all the IP addresses from the interfa
ce, then reassign a new address to it.
We can flush the IP addresses using the below command:


We check the results, using the below command:


Then we can re-assign the IP address using the "ip addr add" command, for example:


If we want the IP address to persist beyond a reboot, we need to put the configuration in the "/etc/network/interfaces" file:

For a dynamic IP address, we use:


Or for a static IP address, we use:


Comments

Leave as a comment:

Archive