So we start by editing the /etc/network/interfaces file, I will be using vim, however you can use any editor you like
sudo vim /etc/network/interfaces
Let’s assume you want to do the changes for eth0, you will see these lines:
auto eth0
iface eth0 inet dhcp
As you can see, the server is set to use DHCP right now.
We will change over from dhcp to static, Edit your file to the following
auto eth0
iface eth0 inet static
address 192.168.0.10 (Change this you whatever address you want to specify)
netmask 255.255.255.0 (Use your subnet mask)
network 192.168.0.0 (Your network address)
broadcast 192.168.0.255 (your broadcast address)
gateway 192.168.0.1 (Your default gateway, ip of fw or router)
Save the Changes and exit the editor
Next we must edit the DNS settings in the resolv.conf file:
sudo vim /etc/resolv.conf
Add
name server xxx.xxx.xxx.xxx (Your Dns Servers, you can add more then one, each nameserver on a seperate line)
Save the Changes and exit the editor
Once this is complete we must restart the network interfaces
sudo /etc/init.d/networking restart
Note.. in some cases you must remove the dhcp client for the changes to work,, If so you can use the following commands
sudo apt-get remove dhcp-client
or
sudo apt-get remove dhcp-client3
and
sudo /etc/init.d/networking restart
Try pinging a site and you should be done..