Set A Static IP Address On Ubuntu 10.04 Lucid Lynx

It is not intuitively obvious how to assign Ubuntu 10.04 Lucid Lynx a a static IP address from the command line. However, much of Linux administration involves the editing of text files, and assigning a static IP address is no different. You’ll need to edit the following file:


Initially, the file only contains information about your local loopback address:

auto lo
iface lo inet loopback

To assign a static IP address, you’ll need to make some changes to this file.

Let’s say you want to assign a static IP of to your eth0 network connection (the first Ethernet adapter on your system; if you only have one, it will be eth0), with a subnet mask of and a local gateway of First, make a backup copy of the interfaces file:

sudo cp /etc/network/interfaces ~

This will make a backup copy in your home directory in case something goes amiss during the editing process. Next, fire up a text editor:

sudo vi /etc/network/interfaces

(Obviously you can substitue emacs or your editor of choice.)

Once the file is open, add the following lines:

iface eth0 inet static

Once you’ve added these lines, save the interfaces file to disk, and exit your text editor. If you want to add a static DNS server, you’ll need to edit the /etc/resolv.conf file with this command:

sudo vi /etc/resolv.conf

To set a static DNS server with the address of, add this line to the file:


Save the file, and exit your text editor.

You’ll then to need have your system load the new IP configuration. You can do that by rebooting, but if that takes too long, you can use this command to force Ubuntu to re-read the configuration files:

sudo ifup eth0

Your system will then have a static IP address.



The Ubuntu Beginner’s Guide

The Ubuntu Desktop Beginner’s Guide.

This entry was posted in Linux, Ubuntu 10.04. Bookmark the permalink.

20 Responses to Set A Static IP Address On Ubuntu 10.04 Lucid Lynx

  1. eric says:

    thanks for the guide. here’s a little typo in it though. there’s a 252 instead of a 255 in your netmask settings.

  2. cory says:

    thanks alot, spent the day wringing my head over this one, pretty sad I remember the same issue with karmic, been through this before. odd that there was one share everyone could access though, you’d think it would be all or none.

  3. Alex says:

    I tried it through Network Manager and it works, but /etc/network/interfaces is not updated. In another installation I updated /etc/network/interfaces as you do here, but Network manager thinks I’m not connected, although I am. I’m guessing on a server without a user login to a GUI, you’d need to do the manual update?

  4. Glyn says:

    Many thanks for publishing this, I’m more a FreeBSD guy so the configuration is very different. Having used Ubuntu as a desktop OS I’m looking at the Server edition with keen eyes for our hospital network, especially as the latest is LTS.

    @Eric – using 252 is perfectly valid, and would give a network range of -> in the above context, but granted it’s not common. Look up CIDR notation (example, a 252 being a /22 network).

  5. Alexey says:

    In the example you are considering the text that you need to add to your /etc/network/interfaces file must be this:

    auto eth0
    iface eth0 inet static

    The difference is in the first line which is missing in your post.

  6. Anurag says:

    you should also add ‘network’ and ‘broadcast’ to connect the linux box from other systems. So the text you need to add to your /etc/network/interfaces file should be:
    auto eth0
    iface eth0 inet static

  7. Pingback: Linux alternative for windows server pt.2 | WWWalter

  8. galefly says:

    I am brand new to Ubuntu… in Windows I would also set two DNS servers. I could point to the gateway or hard code these servers, e.g., the ISP’s or maybe Google’s and would I do that?
    My plan is to redirect a port in my router to the static IP to give me remote access to my Ubuntu desktop… thanks

  9. Paavo says:

    I tried to set static ip in System>Network connections after using DHCP Auto eth0 for some time – my connection disappeared and did not return by resetting to DHCP.

    Above instructions, with Anurag’s modifications, helped.

  10. Nops says:

    Thanks a lot, simple & straight forward!

  11. Rob says:

    Can you specicy two fixed ip’s in the interface text file?

    I have an ethernet card, eth0 as well as a wireless card, wlan0 in my netbook. Only one is active at one time, but I’d like to have a static address for each

  12. Shishir says:

    I have a static ip address which I set using – System->Preferences->Network Connections

    But all I see in the /etc/network/interfaces file is:
    auto lo
    iface lo inet loopback

    Which file will have my static ip address settings?

  13. David says:

    I have my static address as per the instructions, and it seems set. Yet my win2000/AD server continues to allocate a dhcp address, and erase the dns entry in favor of the dhcp address. Any suggestions as to why the ubuntu server continues to request a dhcp address?

  14. olofcadiz says:

    This is a mystery for 10.04
    I have two computers with static IP made by earlier versions of ubuntu and then upgraded to 10.04.
    After new install of 10.04 with DHCP it is impossible to change to static.
    I have tried using the normal way first system>preferences>network or editing from above
    But it does not work. Anybody with the same problem?

  15. wtony says:


    try retarting and then issue the command:
    sudo ifup eth0

  16. Pingback: /etc/network/interfaces for a Linux router - have question-Also DHCP & DNS questions

  17. Richard Kay says:

    Instructions basically work with minor adaptation. Need to check IP of gateway first. netmask is most likely to be for a /24 which is the most typical small LAN configuration on 192.168.x.x . As I was remote ssh logged in to my wife’s misbehaving computer (have to get the order of words right here) the shell disconnected after the previous rogue dhcp address following hardware repair was replaced with the static one intended and to which other things on the LAN were previously configured.

  18. Samson says:

    I have an Ubuntu 10.04 lts as a server. I need to have port 22300 open. I also need to have static IP, which I achieved by reserving that ip for the server on my home router (I will now use the suggested method to eliminate my home router). I configured port forwarding on the ISP WIMAX router but port checker app sees the port as closed, whereas the ISP claimed that the port is open, they even gave my connection a static ip. How do I go about this as no one is able to connect to the server externally.

  19. henro says:

    hi samson,it is obvious that u hav to routers:home router n isp modem router.dis will result to double i advice dat u set ur isp router to bridge mode so dat it doesnt do nat n dhcp function.after dat setup portforwardin on your home router to ur server static add on port 22300.dis should access ur server externally type d static public add followd by :22300