Change the following 2 files

1) /etc/network/interfaces

2) /etc/resolv.conf

Steps

1) sudo vi /etc/network/interfaces

The followings will be seen.

auto eth0
iface eth0 inet dhcp

change to

auto 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

2) sudo vi /etc/resolv.conf

change to

name server 192.168.0.1

name server 8.8.8.8 (optional, this is google’s public DNS)

3) Restart networking

sudo /etc/init.d/networking restart

if fails, use the followings to disable & enable the network card

sudo ifdown eth0

sudo ifup eth0

or just combine the above 2 commands especially when you are not at the console

sudo ifdown eth0 && sudo ifup eth0