How to permanently change the IP address of Ubuntu with CLI only?
By Mia Morrison •
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)
41 Answer
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
$ sudo ifconfig eth0 192.168.80.10 netmask 255.255.255.0or, with the newer ip command, you remove the old address and add the new one:
$ sudo ip address del dev eth0
$ sudo ip address add 192.168.80.10/24 dev eth0 2 More in general
"Zoraya ter Beek, age 29, just died by assisted suicide in the Netherlands. She was physically healthy, but psychologically depressed. It's an abomination that an entire society would actively facilitate, even encourage, someone ending their own life because they had no hope. Th…"