Using Static IP Address On Ubuntu



By default most unix boxes now come with dynamic IP enabled for all its networking needs. This is a very useful configuration but at times it helps to know that a system’s IP will remain the same no matter what changes occur around it. A classic example of this case can be a server.

In any case if you want to change your unix box to use static IP the following simple steps will get your task done:


  1. Edit the /etc/network/interfaces file, it can be opened by the command:
    sudo nano /etc/network/interfaces
  2. The contents of the file will read something like:

    auto lo
    iface lo inet loopback

  3. Replace the text with the following text:

    auto eth0
    iface eth0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    network 192.168.1.0
    broadcast 192.168.1.255
    gateway 192.168.1.1

  4. Finally we need to restart the networking daemon.  It can be done with the following command:
    sudo /etc/init.d/networking restart