Set static IP on Ubuntu

  1. In /etc/network/interfaces

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth0
    iface eth0 inet static
            address "insert the IP you want to set"
            netmask "insert subnet mask"
            gateway "insert gateway"
            dns-domain yourdomain.com
            dns-search yourdomain.com
            dns-nameservers "insert your nameservers IP address separated by spaces"

  2. Please make sure there are no "" in  /etc/network/interfaces file.

  3. Restart networking by running following command:
    sudo /etc/init.d/networking restart

  4. Please leave a comment or g +1 or share on f or share on t below if this post helped you. This will keep me motivating.