How to make ip Address static (eth0)

78,935

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
    
Share:
78,935

Related videos on Youtube

Jordan Angelucci
Author by

Jordan Angelucci

Updated on September 18, 2022

Comments

  • Jordan Angelucci
    Jordan Angelucci over 1 year

    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.

    • Thomas Ward
      Thomas Ward almost 11 years
      Which IP are you trying to get static? And are you using NetworkManager at all?
    • RobotHumans
      RobotHumans almost 11 years
      @Qasim - Removing networkmanager is not a solution. I prefer wicd myself, but it's still not a solution. It could break loads of things to just rip it out. It's a lot like saying, just remove dnsmasq if you want old style DNS management. It could work, but it's not fixing the problem.
    • Qasim
      Qasim almost 11 years
      hmmmmm got it.. comment removed about network-manager
  • guntbert
    guntbert almost 10 years
    How is this different from what the OP shows?