Phone :  +370 (5) 204-1903
Email: sales@1gbits.com
  1. Dedicated server
  2. Blog
  3. How to Set A Static IP On Ubuntu
How to Set A Static IP On Ubuntu


Feb, 18


In this tutorial we will cover the network configuration changes to set a static IP address for a Ubuntu server. In this section, we assume that you have only one interface named 'eth0' after a default installation.

Note: We assume that you are familiar with opening, editing and saving files in the command line.

Network Configuration Commands

In Linux systems there are a few commands that you can use to find out the current network configuration. One of these commands is 'ifconfig' command. Use the following command to see all network interfaces on your server:

ifconfig -a

You can also use ip command:

ip addr

There are several files that you need to edit them to make you networking related configuration. These files are as below:

  • / etc / network / interfaces describes the available network interfaces
  • / etc / hostname configures the nameserver for your server
  • / etc / hosts resolves IP addresses to hostnames

After the new configuration is set, the interface must be restarted.

How to Set A Static IP on Ubuntu

To change the network configuration on the Ubuntu server, you must open the / etc / network / interfaces file. In this section, we want to set a static IP to a system with just one Ethernet interface named 'eth0'. We will configure this interface with IP address. Open this file using a text editor like nano.

Nano / etc / network / interfaces

The file includes the following lines:

# This file describes the network interfaces available in your system 

# and how to activate them. For more information, see interfaces (5). 

# The loopback network interfaceauto loiface lo inet loopback 

# The primary network interface

auto eth0

iface eth0 inet static   







dns -domain acme.com   

dns-search acme.com

In this file you must make changes as described below:

  • Find the line starting with "iface eth0 ..." and change the word "dynamic" to "static"
  • Find the line starting with "address" and change the address to your requested static IP address. Our IP will be
  • Find the line starting with "netmask" and write your correct subnet mask
  • Find the line starting with "gateway" and write your correct gateway address in front of it.
  • Find the line starting with "dns-nameservers" and add your nameserver information

To find your correct IP address, subnet mask, gateway, or dns-nameservers, you must consult with your network administrator for the information.

After configuration accomplishment, restart the interface with the command below. You will lose your connection if you are connected using SSH, connect again using your new IP address:

ifdown eth0; ifup eth0

Congratulations! You have learned how to set up an static IP on Ubuntu .

If you are facing any problem with the steps,feel free to comment here. We will help you to solve the issue.

author img


Leave A Comment