Welcome to Linux Forums! With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.
Find the answer to your Linux question:
Site Navigation
Linux Forums
Linux Articles
Product Showcase
Linux Downloads
Linux Hosting
Free Magazines
Job Board
IRC Chat
RSS Feeds
Free Publications

This article will explain how to set a static IP in Ubuntu server.

The Ubuntu server OS by default installs its network settings as DHCP (dynamic). Anyone who wishes their server to be accessible from outside their network (over the internet) should change this setting to static as any incoming traffic will need permission to enter the network through port 80 on your local network (router/modem). The following will help you to make these changes through ubuntu's command line on your server. One thing to keep in mind, the numbers I use in my example are based on a router whos gateway is This is a very common gateway but it may not be yours. Please check your router configuration for this information before moving on.

The first thing we need to do is get a text editing program called vim-nox. We do this because the text editor that comes with Ubuntu by default has problems making this sort of edit. To get and install vim-nox, in your command line, type:

sudo apt-get install vim-nox

When the vim-nox installation is complete you will be back at the command line. To open your network settings in the text editor, type:

sudo vi /etc/network/interfaces

You should see a few lines of information about your network settings, the last of which should read:

iface eth0 inet dhcp

Navigate to the end of this line and type the letter:


This will enable you to edit the text in this file. The first change you will make to this file is to change:

iface eth0 inet dhcp


iface eth0 inet static

Then you will need to enter the following information about your local network:


Next you will need to save the changes that you just made to this file. To do that, press ESC and type:


Then press enter.

The changes are now made but they will not take effect until the next time the server or network are restarted. To restart your Ubuntu network connection and update the changes you have just made, there is one last step. In your command line type:

sudo /etc/init.d/networking restart

Then press enter and ubuntu will restart its network connection. Now you will be able to configure your router to allow outside traffic to your server through port 80 on IP Everytime you restart your machine, or your router, your ubuntu server will always log on to your local network at the same (static) address. This will save you tons of time and energy from having to change these settings each time on your router. zZoox has a list of other possible router configurations for this method.

Rate This Article: poor excellent
Comments about this article

Comment title: * please do not put your response text here