How to change ip address in ubuntu desktop through command line

Solution 1:

By default, Ubuntu (or Network Manager to be specific) ignores the /etc/network/interfaces file. To make the changes you made take effect, execute the following commands:

sudo ifdown wlan0
sudo ifup wlan0

Assuming that wlan0 is the interface you are editing. Once you do that, wlan0 will come up with the settings you have under its stanza in /etc/network/interfaces.


Edit: since you're connected through SSH. You can try the following:

Edit /etc/NetworkManager/NetworkManager.conf and change ifdown managed to false:

[ifupdown]
managed=false

Then, try:

  • How to restart the networking service?

Solution 2:

Try this. Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:

sudo -i
gedit /etc/network/interfaces

This is done with the help of guntbert

Once done save and exit

add this line DHCP mode

auto eth0
iface eth0 inet dhcp

Static mode

auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
gateway xxx.xxx.xxx.xxx

Once done save the file, and:

sudo service resolvconf restart
  • How to restart the networking service?