How to make ip Address static (eth0)

I'm having a really hard time configuring ubuntu 13.04 to have a static ip address. I have tried multiple solutions but everytime I reboot (can't do the network reset command because ubuntu freezes) I end up with no connection.

Here is what I get when i type ifconfig into the terminal:

eth0      Link encap:Ethernet  HWaddr 10:bf:48:bc:07:cb  
          inet addr:192.168.0.8  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::12bf:48ff:febc:7cb/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:1763067 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1024326 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:2284491220 (2.2 GB)  TX bytes:136809317 (136.8 MB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:1840 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1840 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:185688 (185.6 KB)  TX bytes:185688 (185.6 KB)

I have also tried this:

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
        address 192.168.0.160
        netmask 255.255.255.0
        broadcast 192.168.0.255
        gateway 192.168.0.1
        dns-nameservers 24.222.0.94
        dns-nameservers 24.222.0.95

If anyone could help me it would be very much appreciated.


Follow these steps to make the IP address of a system static:

  1. Open interface file (sudo vi /etc/network/interfaces)
  2. Look for

    auto eth0
    iface eth0 inet dhcp
    
  3. Replace the above commands with

    auto eth0
    iface eth0 inet static
    address 192.168.1.100(Enter desired ip here)
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1
    
  4. Then enter

    sudo ifdown eth0; sudo ifup eth0