Ubuntu - Define a private static IP address

Page 1 / 1

When you install Ubuntu on a machine to use it as a server, it is recommended to set a static IP address on that server to prevent the IP address of the server changes all the time.

  1. Uninstall the network manager (networkmanager)
  2. Configure the network interfaces manually
  3. Restart the network service to apply the changes
  4. Connaitre sa configuration réseau

1. Uninstall the network manager (networkmanager)

To set a static IP and make this setting persists address, you MUST remove the installed Ubuntu network manager. This program tends to do everything he can to keep the network connection, even delete your settings and reset your network connection automatically (Assigning the IP address via a DHCP server).

For this program avoids deleting your custom configuration, the easiest way is to remove :


sudo apt-get remove network-manager-gnome network-manager

Note : The network icon appear in the top bar (Ubuntu Desktop) has disappeared after uninstalling this program.

2. Configure the network interfaces manually

To configure your network interfaces, you must edit the "/etc/networks/interfaces" file.


sudo vi /etc/network/interfaces

By default, you will find the following lines:
Note : This is the configuration of the network card loopback called "local loop". This information is displayed by the command "ifconfig".


auto lo
iface lo inet loopback

Warning, do not delete these lines.
To configure your network interface (eth0), you must add the following lines :
Notes :
- Leave a blank line to separate the two interfaces.
- You can specify the DNS server because as indicated on the Ubuntu website , the utility "resolvconf" uses this file to get the regarding information servers (DNS servers).


auto eth0
iface eth0 inet static
# IP Configuration
# Serveurs DNS

Note : It is mandatory to specify which DNS servers to use as they had previously received from the DHCP server. Being that it has disabled use the DHCP server, we therefore find no DNS server address. It is therefore necessary to specify in order to regain access to google.com ...

If you then want to reset your network dynamic map, you can simply reset dhcp instead of static :


auto eth0
iface eth0 inet dhcp

3. Restart the network service to apply the changes

To restart the network service, you can simply type this command.
Ubuntu will show the command is deprecated but still it works correctly.
We do not recommend using this command stop and start as it crashed we graphical interface of Ubuntu and we did just restart our Ubuntu machine.


sudo /etc/init.d/networking restart

4. Know its network configuration

To know your IP address, MAC address and other information about your network configuration, type the following command :