2.4. Setting a static IP address

If you didn't enter the IP address during the installation of the server, you probably got an address from the DHCP server. Since servers IP address should not be changed you will have to set a static IP address for your sever.

Enter ifconfig at the prompt and copy the output somewhere so you have access to network information you got from a DHCP server.

Open up /etc/network/interfaces with nano and replace

auto eth0
iface eth0 inet dhcp

with

iface eth0 inet static
    address YOUR-IP
    netmask YOUR-NETMASK
    network YOUR-NETWORK
    broadcast YOUR-BROADCAST
    gateway YOUR-GATEWAY
    # dns-* options are implemented by the resolvconf package, if installed
    dns-nameservers YOUR-DNS-SERVERS-SEPARATED-BY-SPACE
    dns-search YOUR-DOMAIN
[Caution]Caution

If you are using another interface for the connection replace eth0 with the interface you are using.

Reboot your server, check that your internet connection is working (try to ping google.com or some other host) and if everything is ok you can remove packages that provide DHCP from your system.

apt-get --purge remove isc-dhcp-client isc-dhcp-common

Note that option –purge removes configuration files of the packages we are removing. If you do not use –purge they will be left on your system.