I have a ubuntu machine and want to change the IP address, the requirements are as follow:-
- using only cli to change the IP address, since the HW is not accessible and the script is changing the IP address through SSH, so it has to be the only cli
- The changes to be permanent, the IP address shouldn't be lost on restart
- This should be applicable to all the version of ubuntu
The ubuntu in question is a VM with the default static IP already configured can be accessed with the SSH.
Is there any way to change the IP address of ubuntu with the above requirement?
preferably it should be supported from version 14 - 20 (only stable build)
Two (of many ways) to do it, say you want the new IP to be 192.168.80.10 with netmask 255.255.255 and your interface is eth0
or, with the newer
ip
command, you remove the old address and add the new one: