Unix Change Static IP

|

It is best to do this on the machine itself and not remotely as you will lose connection.

sudo cp /etc/network/interfaces /etc/network/interfaces.`date +"%m-%d-%Y_%I-%M-%S"`
sudo sed -i 's|address 192.168.1.16|address 10.1.1.16|' /etc/network/interfaces
sudo sed -i 's|netmask 255.255.255.0|netmask 255.255.0.0|' /etc/network/interfaces
sudo sed -i 's|gateway 192.168.1.1|gateway 10.1.1.1|' /etc/network/interfaces
sudo service resolvconf restart
sudo /etc/init.d/networking restart
sudo reboot
Originally Posted on November 5, 2015
Last Updated on December 29, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.