Change Ubuntu System from DHCP to a Static IP Address

Sponsored Link
If Your Ubuntu System has set to use DHCP, you will want to change it to a static IP address here is simple tip

open the /etc/network/interfaces file.

sudo vi /etc/network/interfaces

If you are using DHCP for your primary network card which is usually eth0, you will see the following lines

auto eth0
iface eth0 inet dhcp

As you can see, it’s using DHCP right now. We are going to change dhcp to static, and then there are a number of options that should add and here is the example and you can change these settings according to your network settings.

auto eth0
iface eth0 inet static
address 192.168.1.100
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1

Restart the neworking service using the following command

sudo /etc/init.d/networking restart

Incoming search terms:

Related posts

40 thoughts on “Change Ubuntu System from DHCP to a Static IP Address

  1. You can also view (and change) your connection w/ ifconfig. See man pages for options. ifconfig will provide current detail about your eth0 NIC before changing.

    [Reply]

  2. What if I have network-manager installed (everything is commented out in /etc/network/interfaces except lo)

    How can I set up a static IP?

    Thanks

    [Reply]

  3. Hi,

    I have installed ubuntu server 7 on my box and connected to my router speedport 5020. As long as I use dhcp client, the connection to the internet works fine.
    I would like to use the box as file server with ssh, so I need a static address to it.
    The router assignes by dhcp 192.168.2.100 – 192.168.2.197, so I gave to my box the static address ending .198

    I edited my /interfaces and it looks like this
    #######################
    auto lo
    iface lo inet loopback
    auto eth0
    iface eth0 inet static
    address 192.168.2.198
    netmask 255.255.255.0
    network 192.168.2.0
    broadcast 192.168.2.255
    gateway 192.168.2.1
    ######################

    moreover I have for my resolv.conf

    ################################
    search Speedport_W_502V_Typ_A
    nameserver 192.168.2.1
    ################################

    anyway I cannot ping the ouside world, and from computers in the same network I cannot ping mx box.

    if I ping from my box a computer in the network I get “Destination host unreachable”

    It seems to me that I have done everything as in the instructions above. Does anybody any Idea of what can be wrong ?
    I am quite a beginner so I am compeltely lost …

    Regards

    Marco

    [Reply]

  4. I really need help
    after changing my IP setting
    sudo /etc/init.d/networking restart just doen’t work

    Please advise

    [Reply]

  5. I really need help
    after changing my IP settings

    how to i save and restart.

    i tried using
    sudo /etc/init.d/networking restart but it does not restart

    pls advice me if i doing the right thing…

    [Reply]

  6. if you’re having problems with
    sudo vi /etc/network/interfaces
    try
    sudo nano /etc/network/interfaces

    [Reply]

  7. I need to set a internet static ip on ubuntu. Unfortunately, my connection pass by a router that have a public ip on internet. when i set public static ip, y ubuntu computer can’t go on internet. What’s the way to resolve? Thnx

    [Reply]

  8. @Cesco

    you need to make sure which DNS servers you are using in your ubuntu system

    you need to edit the following file

    sudo nano /etc/resolve.conf you need to add your isp DNS servers with the following syntax

    nameserver X.X.X.X
    nameserver X.X.X.X

    X.X.X.X – Your ISP DNS servers

    save and exit the file

    [Reply]

  9. I’m at the start point! I’m connected with wlan0 interface configurated with an internal ip, and wlan0:0 configurated with an external ip. But network is unrecheable. :(

    [Reply]

  10. Hi, I’m trying to set up a static IP to get Azureus working properly

    Using sudo nano /etc/network/interfaces

    I added the following to my /etc/network/interfaces:

    auto lo
    iface lo inet loopback
    auto wlan0
    iface wlan0 inet static
    adress 192.168.2.200
    netmask 255.255.255.0
    network 192.168.2.0
    broadcast 192.168.2.255
    gateway 192.168.2.1

    then restart using

    sudo /etc/init.d/networking restart

    During this process it gives me the following:

    * Reconfiguring network interfaces…
    Don’t seem to be have all the variables for wlan0/inet.
    Failed to bring up wlan0.

    I don’t understand what variables are missing…
    I tried the same configuration with eth0 and it gives me a similar message

    Thanks in advance to anyone who could shed some light on this problem

    Jess

    [Reply]

  11. Hi again, I came across an alternative solution!

    Just use Wicd instead of network manager, as network manager doesn’t support static IPs.

    To get Wicd just follow the instructions here

    Hope that helps

    Jess

    [Reply]

  12. hi i tried to fix my connection that way but i didnt succed .. i tried in kde 2.4 im newbie .. please help i put the ip netmask gateway and dns corectly but does not connect .. what should i do next .:( i tried modify that document .. but dont work .. please help .. and please email me whit some answers

    [Reply]

  13. I had some trouble getting the settings to work,
    the error I made was to omit the line “auto eth0″, it is essential!
    The lines network and broadcast can safely be omitted, they are calculated automatically from the address and netmask values.

    [Reply]

  14. Worth mentioning here is that you can specify the DNS server IP#s from opendns.com in /etc/resolv.conf if you want. Alternately, you could leave the nameserver IP# in /etc/resolv.conf as your router’s IP#, and using static DNS server IP#

    I have found opendns.com’s DNS servers to be much faster than many ISP’s, and my ISP would typically do service on their DNS servers over the weekend and our home router and it would be slow in relaying the changing DNS server IP#s

    [Reply]

  15. I cloned the recipe and tried it… only to find out that I can no longer reach the network. Then I added the lines
    dnsserver X.X.X.X
    to the ones above, and the static IP worked :)
    thanks a lot :D

    [Reply]

  16. Please let me k now after edit the following
    sudo vi /etc/network/interfaces

    how can I save that.
    Please…
    I am a beginner

    [Reply]

    admin Reply:

    press Esc and :wq!

    This will save and quit your file

    [Reply]

Leave a comment

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