Most servers have static IP addresses. You can either set a reservation in your DHCP scope (this could spell disaster if the DHCP server is unavailable or there is a networking related issue) or you can manually set a static IP address in Linux configuration files.

This guide will help in manually setting a static IP address through editing of Linux configuration files.

 

The things you will need before starting:

  • An understating of basic network configurations
  • Access to a Debian-based Linux Desktop or Server
  • Access to the root account or an account with sudo access.
  • Basic knowledge of text editing software such as Vi, Vim, Nano, Pico, Gedit, etc.

Steps:

  1. Log in as either root or a user with sudo access.
  2. Open a text editor (this may be completed while opening the document or before).
    Example (note that if you are logged in as root you may omit the "sudo" command):
    sudo nano
    sudo pico
    sudo gedit
  3. The location of the configuration file is /etc/network/interfaces
    I use vim the most frequently, so my command will look like this:
    sudo vi /etc/network/interfaces
  4. Once the file is open, the document will look similar to this:
    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet dhcp
  5. We want to edit the configuration file to look more like this:
    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 192.168.16.10
    netmask 255.255.255.0
    gateway 192.168.16.1
    network 192.168.16.0
    broadcast 192.168.16.255
    dns-nameservers 192.168.16.1 8.8.8.8 8.8.4.4
  6. Once the files have been edited, save, and restart the networking deamon
    sudo /etc/init.d/networking restart
    or reboot the desktop/server
    sudo reboot

 The desktop/server should now be available at the IP address you've set.