Linux - Change IP (Ubuntu 20.04+)

Modified on Mon, 14 Mar 2022 at 05:07 PM

Assumptions

  • Ubuntu 20.04+
  • netplan installed
  • NIC Bonding Optional


1. Firstly to save headaches run all commands as su

     sudo su


2. Backup the current configuration

     cp  /etc/netplan/00-installer-config.yaml  /etc/netplan/00-installer-config.yaml.tmp


3. Edit config file

     nano /etc/netplan/00-installer-config.yaml 


File Structure is:


(Format for bonded is similar)



4. Edit IP details


5. CTRL + X to save & exit


6. Test settings (optional)

       netplan try


7. Apply settings

       netplan apply



In case of broken networking

if the above breaks the network config, firstly revert settings and then run netplan apply

if this doesn't work, run these commands to revert files.


rm /etc/netplan/00-installer-config.yaml 

mv /etc/netplan/00-installer-config.yaml.tmp /etc/netplan/00-installer-config.yaml

netplan apply

reboot





Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article