Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question

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.

share|improve this answer

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.

share|improve this answer
if anyone stumbles in here as me - on an openSuse environment this should /etc/rc.d/boot.local – Nuno Furtado Mar 31 at 12:44

You must log in to answer this question.

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