M BUZZ CRAZE NEWS
// general

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)

4

1 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.0

or, 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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy