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:
iface eth0 inet static
To make dns work the file /etc/resolv.conf should contain the following:
That's all, restart the networking service or reboot the server to activate the changes.
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):
iface eth0 inet dhcp
After changing the setting you need to restart the networking service or reboot the server.