I have configured network adapter of guest Ubuntu to work in a bridged mode so I could ssh to it from the host machine.

The problem is that the guest Ubuntu ip address keep changing.

Even though it changes within a very short range it is still takes time to configure Putty and other programs each time.

Is there a way to make the guest Ubuntu ip address to be static?

My guest OS has the full GUI.


To give static ip address graphically

1.Go to network connections

2.Then edit the connections in the wired settings

3.Add the ip address for the system

Here are the images below

Network Connections


If you are curious, You can find newly created connection from the above steps as configurations file at /etc/NetworkManager/system-connections

  • 1
    You are the champion. With you answer I managed to configure my Ubuntu and Fedora in a seconds. Though I had to restar the Fedora. – Mitten Aug 29 '13 at 12:17
  • Happy to Help :D – Tarun Aug 29 '13 at 12:18
  • the save button is not enabled. What should be the ip address of DNS servers. – Arun Raja Nov 17 '15 at 11:03
  • This was a temporary solution for me. It worked while I struggled to configure two routers to work together. Then it failed and I had to switch back to automatic DHCP. BTW, the Ziggo/Cisco EPC3925 wireless/cableTV gateway/router is a flaming POS. – Diogenes Dec 9 '15 at 8:38

Edit /etc/network/interfaces to reflect something like this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
address 192.168.0.X
gateway 192.168.0.X
dns-nameservers 192.168.0.X

Then do a:

sudo /etc/init.d/networking restart

And that will get you fixed up.

  • @Mitten if this answer solved your question pleas mark it as accepted! – Braiam Aug 29 '13 at 12:38
  • 1
    Correction: /etc/network/interfaces. Also, if the static address is routable (in DNS, instead of e.g. 192.168.x.x), edit /etc/hosts and /etc/hostname to match. – Camille Goudeseune Dec 23 '13 at 18:50
  • How do I do this under Ubuntu 17.04? These instructions don't work for that. I'm happy to use either vi or emacs. – Erik Bennett Aug 16 '17 at 14:49
  • i have ens33, so should i change eth0 to ens33 , should i restart the system – Code May 22 '20 at 8:14

OP posted:

Setting Static IP

sudo nano /etc/network/interfaces #  I use vi instead of nano

When you open up the interfaces doc, you will see something like this:

auto lo eth0
iface lo inet loopback
iface eth0 inet dynamic

You want to change it to incorporate the following:

auto lo eth0
iface lo inet loopback
iface eth0 inet static
        address xxx.xxx.xxx.xxx (enter your ip here)
        netmask xxx.xxx.xxx.xxx (mine was
        gateway xxx.xxx.xxx.xxx (enter gateway ip here,usually the address of the router)

Save your changes and exit.

Then I needed to add some dns info to resolv.conf so I opened up the file like so:

sudo nano /etc/resolv.conf # I use vi instead of nano

Initially this file is empty excluding a warning of "Do not put anything in here it will be overwritten". I added the following information none the less.

This is the format:

nameserver xxx.xxx.xxx.xxx(enter your dns server ip)
nameserver xxx.xxx.xxx.xxx(enter your alt dns server ip)

This is what I entered:


Save your changes and exit.

At this point you can either restart networking:

sudo /etc/init.d/networking restart  

or reboot which is what I did:

sudo reboot

Once I was logged back in I tried the install again of pure-ftpd and all is good:

apt-get install pure-ftpd

I hope this helps someone, I looked around for the fix and just happened upon it by accident.

  • 1
    Community wiki or something? :) – moon.musick Sep 9 '13 at 13:05

On Ubuntu 18.04 LTS and Ubuntu 20, Netplan is available and replaced ifupdown by default. Let's say our interface is ens192. To check whether it's being managed by NetworkManager:

cat /run/NetworkManager/conf.d/netplan.conf

Which could output this:

# devices managed by networkd

Backup the configuration file (your path or file may be different):

cp /etc/netplan/01-netcfg.yaml /etc/netplan/01-netcfg.yaml.ori

Then edit /etc/netplan/01-netcfg.yaml to look something like:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
  version: 2
      dhcp4: false
      wakeonlan: true
        addresses: []

Generate the output file with debug for extra details:

sudo netplan --debug generate

We'd like to see:

DEBUG:command generate: running ['/lib/netplan/generate']
** (generate:9991): DEBUG: 18:08:30.447: Processing input file //etc/netplan/01-netcfg.yaml..
** (generate:9991): DEBUG: 18:08:30.447: starting new processing pass
** (generate:9991): DEBUG: 18:08:30.448: ens192: setting default backend to 1
** (generate:9991): DEBUG: 18:08:30.448: Generating output files..
** (generate:9991): DEBUG: 18:08:30.449: NetworkManager: definition ens192 is not for us (backend 1)

We can see the actual configuration with:

cat /run/systemd/network/10-netplan-ens192.network

Let's make it active by:

sudo systemctl restart systemd-networkd

Be prepared to lose the connection if doing this over SSH. Do man netplan for details. There is also a related answer on this site. See also the documentation.


It seems the interface eth0 was configured before and the address was kept persistently (for some reason) by the kernel.

To clear all addresses from interface eth0 without having to restart network services or bringing the interface up/down :

sudo ip addr flush dev eth0

Then you can use ifup to configure eth0 by reading /etc/network/interfaces file :

sudo ifup eth0

For verbosity :

sudo ifup -v eth0

The only thing that worked for me was:

  • go into modem config (
  • set up DHCP Reservation Lease: it maps LAN IPs to MAC addresses
  • set the interface to use DHCP (the default, modifiable on NetworkManager at nm-connection-editor)
  • This is not an answer, but a workaround only if the router belongs to the user. – Charith Jayasanka Mar 27 at 17:32

==== Configure static IP on Ubuntu 14.04

in file /etc/network/interfaces

iface eth0 inet static


sudo ifup eth0

need some time to take effect

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