Network

Static IP

In the following example configuration I assume the machine IP address to be 192.168.0.2, the gateway and dns are located on 192.168.0.1.
Within a Debian/Ubuntu(non-gui) setup change the file /etc/network/interfaces to have the following lines:

allow-hotplug eth0
iface eth0 inet static
address 192.168.0.2
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1

To make dns work the file /etc/resolv.conf should contain the following:

nameserver 192.168.0.1

That's all, restart the networking service or reboot the server to activate the changes.

Dynamic IP

If the IP address should be dynamically assigned to an interface you need the following lines in /etc/network/interfaces instead(you can leave resolv.conf untouched):

allow-hotplug eth0
iface eth0 inet dhcp

After changing the setting you need to restart the networking service or reboot the server.