Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I use static IP adresses.

When changing the IP of a network interface (eth0 or wlan0) the settings are saved to the network connections but when running ifconfig or looking at Network Settings, either connections retain the old IP address.

I have tried restarting the networking service, the computers (yes, this occurs on more than one) and even reinstalling the OS.

PLEASE can somebody help me. I'm losing out on so much work this past week just trying to get Ubuntu 12.04 working like a normal OS.

Using the command sudo ip addr add dev eth0 SOMETIMES works... the command switches the interface off, then when re-enabling it the IP reverts again. AAARGH!

share|improve this question
Does it help to turn off the device via sudo ifconfig eth0 up and turn it on again with sudo ifconfig eth0 down. Does this help? –  jPlatte May 3 '12 at 8:41
I have tried doing so, when the interface is up again it reverts to the old IP settings. Problem is whenever I change the IP, the interface goes down with the correct settings until I turn it on again. –  beanaroo May 7 '12 at 9:19

2 Answers 2

I`m not a geek! I just want to share my experience. try stopping some services like network-manager! like: sudo service network-manager stop I could not change my mac... but after stopping network-manager I could change my mac permanently. remember not to restart it, but to change settings during the stopped services!!!

share|improve this answer
Thanks, samphil. Turning off / restarting the network-manager doesn't seem to have an effect. –  beanaroo May 7 '12 at 9:20

In general, your process will be:

  • Stop network-manager
  • bring the interface down
  • assign the address and netmask (using ifconfig)
  • optionally create a route to a gateway if the interface is the one that will access the internet (using route)
  • bring the interface back up
  • and either:
    • If DHCP-managed IP address assignment as defined in /etc/network/interfaces:
      • do nothing.
      • service network-manager force-reload
    • If Static IP address assignment as defined in /etc/network/interfaces:
      • change (or define) the IP, netmask, broadcast, gateway as needed
      • service network-manager force-reload

Of course, network-manager is capable of assigning static routes too. Just define your static route in network-manager GUI and then service network-manager force-reload at terminal. Done.

Or switch back to DHCP-assigned dynamically by removing the static route definition from network-manager GUI, then service network-manager force-reload at terminal. Done.

Or you can do it...

The harder way

Which also happens to be the logically flawless, sure-fire way.

These instructions assume your interface is "eth0". If it's not, you'll need to change all commands and areas entered to reflect your interface.

First, check if network-manager is running:

service network-manager status

If it is running, right-click on Network-Manager and click "Edit connections...". Select the [interface] you're having trouble with, and click "Edit...". Click on the "IPv4 Settings" tab. If you see any entries under "Addresses", delete them. "Save" the settings, and close Network-Manager out.

Then, at a terminal, these four command strings, replace brackets and inner bounds area with value:

sudo service network-manager stop;
sudo ifconfig eth0 down;
sudo ifconfig eth0 [static IP you want] netmask [netmask; generally] up;
ifconfig eth0;

You should see that your interface now has the address you want, but we're not done. To make the settings persistent (i.e., across reboots), you'll need to edit (as root) /etc/network/interfaces, and either find the section related to your [interface], or you'll add a new section, separating each section (each "section" defines one interface) by a blank line:

Example (If already exists in file, looks like or similar to):

auto eth0
iface eth0 inet dhcp

Example (Change to this, or add if doesn't exist):

auto eth0
iface eth0 inet static
      address [ip address goes here]
      netmask [netmask goes here]
      broadcast [for netmask, this should be x.x.x.255 where x from IP]
      (optional here, if this is will be your internet interface, "gateway [gateway addr]" goes here)

Of particular note is that you don't want dhcp-assigned IP, you want static-IP. Note the difference in structure between the above two examples.

Save it.

Now if this interface will be meant for internet or external routing (i.e., communication on the interface needs to be able to access IPs outside of the network of the interface, which is defined by your netmask ultimately), then:

At terminal:

sudo route add default gw ["inside local" IP address of your router or other gateway]

Verify your settings are correct with:

sudo ifconfig eth0|grep addr && route|grep UG|awk '{print "Gateway:", $2, "Interface:", $8}';


sudo service network-manager force-reload

...to restart network-manager. At this point you should be good to go.

In the future:

If you need to change your static IP to another static IP after this, it's as simple as sudo service network-manager stop as exampled above, sudo ifconfig eth0 down, edit /etc/network/interfaces as exampled above and changing the IP address to taste, sudo ifconfig eth0 [ip address] netmask [netmask] up as exampled above, and then sudo network-manager force-reload as exampled above, in that order.

If instead you want DHCP to assign IP addresses automatically to the interface, it's as simple as sudo service network-manager stop as exampled above, sudo ifconfig eth0 down, edit /etc/network/interfaces as exampled above and remove the lines address, netmask, broadcast, gateway, and change the part that says static to dhcp, sudo ifconfig eth0 netmask up, sudo service network-manager force-reload. Done.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.