Static IP address on Ubuntu 8.10

Last Friday I upgraded my install from Ubuntu 7.04 to 8.10 Intrepid Ibex on my office workstation and I noticed that I was unable to assign static IP to the machine. After reboot the netmask was getting messed up and reset to 22. Look at this bug for more info.

So, I ditched the native ubuntu Network Manager and installed wicd which is another open source network manager that works with Ubuntu. But after configuring wicd with the static IP, I had another problem. Everytime I restarted the machine, I had to manually start the wicd network manager. Instead of trying anything more with wicd, I decided to ditch a network manager altogether and just configure the files myself.

So, to get the network working with static IP, first remove the network manager (Many people have said that it is not necessary, but I prefer to remove it as I wont be using it anyway):

sudo apt-get remove --purge network-manager

Then modify the /etc/resolv.conf with the dns servers and domain names:

search foo.bar.com bar.com
nameserver 192.168.0.1
nameserver 192.168.0.2

Now, modify /etc/network/interfaces and add

auto eth0
iface eth0 inet static
address 192.168.0.10
netmask 255.255.252.0
gateway 192.168.0.253

Now, just restart the networking:

sudo /etc/init.d/networking restart

Obviously, you should figure out the netmask, gateway and name servers before you start these steps.

This is all that you need to do to configure the machine with a static IP.

30 thoughts on “Static IP address on Ubuntu 8.10

  1. Jeff

    I followed your instructions, but ran into problems. After looking, I noticed that the instruction
    iface inet eth0 static
    is incorrect. It should be
    iface eth0 inet static
    I was able to proceed after that change.

  2. nullrend

    Yeah, I found out the hard way the only way to make Ubuntu 8.10 actually use static IP addresses is to get rid of network-manager (check my comment here (it’s the very last one). This is pretty important for people wishing to use Host Networking for VirtualBox, like myself.

    @Gregory: It is true there should be no need to remove it, but that is why this seems to have been classified as a bug.

  3. rajendra

    There is no need to remove Network Manager
    just modify modify the
    /etc/resolv.conf with the dns servers and domain names:

    nameserver #.#.#.#
    nameserver #.#.#.#

    Now, modify /etc/network/interfaces and add

    auto eth0
    iface eth0 inet static
    address #.#.#.#
    netmask #.#.#.#
    gateway #.#.#.#

    and this is all……

  4. rajendra

    and
    for restart networking
    type in terminal
    sudo /etc/init.d/networking restart
    like mentioned above………:d
    srry for incomplete information

  5. kabel

    @rajendra: i’ve done everything you said, after the restart my computer boots with dhcp, not static ip, so the network manager is realy messed up, removing the network manager was the only way to fix the problem with static ip, or i should have say to remember the changes after the reboot.

  6. rajendra

    @Kabel: i didn’t removed the network manager, n for me its working properly….
    so i really don’t know what u hv done…

    so u should try once more step by step…

    just modify modify the
    /etc/resolv.conf with the dns servers and domain names:

    nameserver #.#.#.#
    nameserver #.#.#.#

    Now, modify /etc/network/interfaces and add

    auto eth0
    iface eth0 inet static
    address #.#.#.#
    netmask #.#.#.#
    gateway #.#.#.#
    for restart networking
    type in terminal
    sudo /etc/init.d/networking restart

    hey don’t forget saving all files…

    even after dis u r in trouble
    u may stick to the upper post…
    but do it in correct way…

  7. userwaldo

    I finally got a static IP to work using the Network Manager.

    I had to do the following.
    Set my /etc/network/interfaces as follows:
    _______________ /etc/network/interfaces _______________
    # The loopback network interface
    auto lo
    iface lo inet loopback

    # Wireless interface
    auto wlan0
    #iface wlan0 inet dhcp

    # The primary network interface
    auto eth0
    #iface eth0 inet dhcp

    # The secondary network interface
    auto eth1
    #iface eth1 inet dhcp
    _________________________________________________________

    Then after a reboot I had to remove auto eth0.
    Then I created a new wired connection called Wired Ethernet 1.
    Once I did this I was able to set a static address and this new profile was written to
    /etc/NetworkManager/system-connections

    I’ll look at getting a bridge network up for Virtual Box later.

  8. Pingback: How I got networking and DNS to work in Ubuntu Intrepid | Krusty Ruffle Babbles

  9. JAVE

    Wahey! That was just what I needed.
    I decided to check out Ubuntu (after using FreeBSD for ages), and was getting really fed up with that network manager thing.
    For some reason my resolv.conf would get wiped every time.

    I’m still not used to all these graphical config things. Why do you think a Unix system comes with a shell & vi?

    grtx,
    JAVE

  10. xenonn

    Would anyone care to enlighten me on how to
    modify
    /etc/network/interfaces
    if I’d like to set up a static ip over wireless.
    I don’t really use eth0 on my desktop and
    I’m a newbie to setting up wireless on linux.

  11. artist

    To set static IP:

    Need not to remove NetworkManager.

    First to edit (as root) /etc/NetworkManager/nm-system-settings.conf:

    [ifupdown]
    managed=true

    then edit your /etc/network/interfaces and /etc/resolv.conf for your IP and name server.

    then reboot.

  12. Jay

    What do we do when we have multiple internet connections? What would go in for the /etc/resolv.conf?

    Example: My configuration is as as follows..
    auto lo
    iface lo inet loopback

    # Wireless interface internet connection 1
    auto wlan0
    iface wlan0 inet dhcp

    # The primary network interface internet connection 2
    auto eth0
    iface eth0 inet dhcp

    Both are different providers with different nameservers

  13. success

    For those who followed artist’s instructions and still having problems with resolv.conf being overwritten, the following fixed it for me and I no longer need to modify resolv.conf and have not removed network manager (but made artist’s changes). Directions copied from here: http://en.kioskea.net/faq/sujet-979-having-a-static-ip-address-under-ubuntu-8-10

    DNS

    If you want to make use of specific DNS, modify the following file /etc/resolv.conf
    Note that if you are using DHCP on one of your interfaces, the contents of this file will be overwritten by the DHCP client.

    To force the DHCP client to use a specific DNS, edit the file /etc/dhcp3/dhclient.conf

    Add the following line:
    prepend domain-name-servers 208.67.222.222,208.67.220.220;

    DNS returned by DHCP are will be added after the DNS you specified.

  14. success

    Oh, should have added that the DNS addresses in the directions above point to the opendns.com servers. You are free to use them or replace with your own dns address. See opendns.com for more info/restrictions.

  15. artist

    I’m sorry as what success said I had problems with resolv.conf, too. But I could not return here to point the problem until I got the e-mail with success’s reply (There is the URL here in the e-mail).

    I have ever wrote a file with DNS message and add a script auto to copy the message to the resolv.cionf after every reboot. But I thought it’s not a good way.

    Then I found that what I had to do is only to remove the line “auto eth0″ in /etc/network/interfaces. Then NetworkManager will not rewrite resolv.conf again. Simple! :D

    Thank success.

  16. artist

    To manoj: I think you can use “Synaptic Package Manager” in the menu of “System -> Administration” to install it if your system is UBUNTU Linux.

  17. artist

    I’m sorry I found I had the problem of resolv.conf too what as success said after I wrote that message. But I could not return here until I got an e-mail with success’s reply ( there is the URL here in it).

    Firstly I wrote a file with DNS message and wrote a script for auto copy the DNS message from the file to resolv.conf after every reboot. But I thought it’s stupid and then try again.

    Actually, the only thing have to do is to remove the line “auto eth0″ from /etc/network/interfaces, then NetworkManager wil not rewrite resolv.conf again. :D

    Success, Thank you.

  18. pew pew pew

    To manoj.
    Use the Ubuntu installation CD. Synaptic Package Manager can install packages from the CD.

  19. Rico

    And how about two configurations — one with static manual IP, and the other DHCP?

    I was switching from Fedora, but after struggling with this for a day now I think not. Strange, I had been hearing about how everything just worked with Ubuntu….

  20. dedi

    after you remove ( sudo apt-get remove –purge network-manager )

    #just edit file /etc/rc.local
    #give command
    ifconfig eth0 inet [your-ip] netmask [your-netmask]
    route add default gw [your-gateway]

    #and edit /etc/resolv.conf for DNS SERVER. after your PC reboot your system will reading this configuration

  21. hawks

    I would just like to say thanks, after looking around the web and even ubuntu own site for help. I can across this, WORK 1st time for me :)

  22. Pingback: How I got networking and DNS to work in Ubuntu Intrepid

  23. Pingback: Static IP address in Ubuntu | TurboLinux Blog

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>