Menu
InformatiWeb Pro
  • Index
  • System admin
  • Virtualization

Login

Registration Password lost ?
FR
  • Windows Server
    • WMS 2012
    • WS2012 R2
    • WS2016
  • Citrix
    • Citrix NetScaler Gateway
    • Citrix XenApp / XenDesktop
    • Citrix XenServer
  • VMware
    • VMware ESXi
    • VMware vSphere
    • VMware Workstation
  • Microsoft
    • Hyper-V
  • RAID
    • Adaptec SmartRAID
  • UPS
    • APC Back-UPS Pro
  • InformatiWeb Pro
  • System admin
  • Linux
  • Define a private static IP address on an Ubuntu server
  • Linux
  • 11 January 2014 at 20:48 UTC
  • InformatiWeb

Define a private static IP address on an Ubuntu server

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.

Warning : this tutorial is outdated.
Recent versions of Ubuntu now use Netplan instead of the old "/etc/network/interfaces" file (which no longer exists).

  1. Uninstall the network manager (networkmanager)
  2. Configure the network interfaces manually
  3. Restart the network service to apply the changes
  4. Know its network configuration

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 :

Bash

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.

Bash

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".

Bash

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).

Bash

auto eth0
iface eth0 inet static
# IP Configuration
address 192.168.1.6
netmask 255.255.255.0
gateway 192.168.1.1
# Serveurs DNS
dns-nameservers 192.168.1.1 8.8.8.8

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 :

Bash

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.

Bash

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 :

Bash

ifconfig

Share this tutorial

Partager
Tweet

To see also

  • Debian - Install and secure a complete mail server

    Linux 2/25/2015

    Debian - Install and secure a complete mail server

  • Debian / Ubuntu - Block attacks (mail, web and FTP)

    Linux 7/7/2015

    Debian / Ubuntu - Block attacks (mail, web and FTP)

  • StartSSL - Renew your SSL certificates

    Linux 9/8/2016

    StartSSL - Renew your SSL certificates

  • Ubuntu - Securing your dedicated server or VPS with Iptables

    Linux 2/28/2014

    Ubuntu - Securing your dedicated server or VPS with Iptables

Comments

You must be logged in to post a comment

Share your opinion

Pinned content

  • Software (System admin)
  • Linux softwares
  • Our programs
  • Terms and conditions
  • Share your opinion

Contact

  • Guest book
  • Technical support
  • Contact

® InformatiWeb-Pro.net - InformatiWeb.net 2008-2022 - © Lionel Eppe - All rights reserved.

Total or partial reproduction of this site is prohibited and constitutes an infringement punishable by articles L.335-2 and following of the intellectual property Code.