It’s not recommended to assign IP address to servers using DHCP since the IP address can change after the lease expires. Just imagine having all the users or devices that need access to the server stopping because the server changed IP address.
In Ubuntu/Linux the process of assigning a static IP to the server is an easy task that only requires the modification of one file and issuing a few commands.
Using you favorite text editor open the file /etc/network/interfaces.
sudo nano /etc/network/interfaces
This is how the the /etc/network/interfaces file looks like.
# 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 dhcp
You can safely erase all the information for eth0 and add the information below. Make sure to change the information in order to meet your networking requirements.
auto eth0 iface eth0 inet static address 192.168.1.10 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255 gateway 192.168.1.1
After adding the appropriate networking information you can restart the networking service for the new changes to take effect.
sudo /etc/init.d/networking restart