I know there are several tutorials on how to manually change IP settings. However, I have yet to find a solution that fits my needs. I need to be able to script something that changes the IP address settings of a host machine. I have tried /sbin/ifconfig eth0 netmask; /sbin/route add default gw

This solution works until the machine is rebooted. I have tried running the scripted solution at @reboot by crontab from root. However, the settings do not take effect. I have noticed too that /etc/network/interfaces settings do no change after making ifconfig calls.

Is there a way to change IP address settings using ifconfig so that the settings do not change on reboot?

5 Answers 5


You likely have your machine set to DHCP at boot...


sudo vi /etc/sysconfig/networking-scripts/ifcfg-eth0

change BOOTPROTO to BOOTPROTO="static"

Then add in your settings... Mine looks like this:


Save and do:

sudo service network restart

Now your IP address is static and won't change after reboot.

  • there is no sysconfig in etc in debian in 2019... debian 9 May 1, 2019 at 15:47

The solution I am currently using is to put said commands in /etc/rc.local. It is tested and this option is found to work.

  • if anyone stumbles in here as me - on an openSuse environment this should /etc/rc.d/boot.local Mar 31, 2016 at 12:44

In order to change your ip address using ifconfig, and have it survive a reboot, you must do the following:

  1. ifconfig eth0 down
  2. ifconfig eth0
  3. ifconfig eth0 up
  4. Then in the upper right hand side of the screen, click on your connection settings icon and click 'connect'. You should be good to go.

This literally just happened to me. I remembered it happening a long time ago and when I saw the first answer posted to this thread, I know I didn't go through that long process before. After some quick reading I realized you must pull eth0 down before re-assigning it, otherwise the connection isn't broken and the ip change won't survive a reboot.


In debian9 stretch I face same issue that after reboot ip changes automatically to DHCP even if IP set as static in /etc/networking/interface as a static. In debin 9 I found

vi /etc/systemd/network/99-dhcp.network

file look like


and chenged to


In my S390 Debian, changing /etc/network/interfaces did the job. Ifconfig made temporary change until the next system restart.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .