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. :wq! is incorrect, it will ignore any errors and “force save” so if you don’t have permissions you would never know as it would just exit. You need to do :wq without the “!”

    [Reply]

  2. note:
    for me, i put the “network” and the “gateway” feilds as the same ip address as my router (in windows called a default gateway)
    and it worked a-ok!
    “address” refers to the ip address that i want to assign to my computer. i have no idea what broadcast is but it is always the same.
    thanks,
    alex

    [Reply]

  3. FYI:

    “network” and “gateway” is usually the same, where the router is connected to the pc/mac.

    However, if you have a router connected to a router and it is connected via Ethernet cable and the following is true:

    – Disabled DHCP in the router and the server (for noobs, DHCP automatically assigns IPs to machines like pc and printers etc.)

    – Assigned static IP within your network.

    – you recently installed Ubuntu on your pc and is using wireless to connect to the router for internet.

    If the above is true, then the “network” should be the IP address you have set for the server. Then the gateway (which is the router in this case) will have the router’s IP address.

    Hope this helps somebody, somewhere.

    By the way, thanks to admin (left message here on Aug 25, 2010 at 5:54pm), Jordon Bedwell (Sept 20, 2010 at 1:50am) and alexanderhspencer (oct 21, 2010, 2:08am) that helped me understand the above article.

    [Reply]

  4. hai,
    i have the problem in node controller.the problem is network unreachable.What i have to do to clear this error.Please reply me .
    Thank you.

    [Reply]

  5. Hi all

    This site has been really helpful to me, God bless u all. I av a live cd called Koha-live-cd. it is pre-compiled with ubuntu. after installing it on my pc, each time i reboot the pc, a webpage displays by default all the applications and username and password to access them. is there any way to remove the webpage. it comes up automatically.
    Thanks

    Dele

    [Reply]

  6. Also don’t forget to edit /etc/resolv.conf and add your DNS nameservers there, as you are not getting the DNS configuration via DHCP anymore and your machine is probably not resolving any hostname. Just add lines of the sort:
    nameserver 1.2.3.4
    nameserver 5.6.7.8

    [Reply]

  7. My /etc/network/interfaces only mentions the LO network. Configuration of ETHx and WLANx seems to be buried inside of WICD (or net manager) somewhere. Am I supposed to edit this file anyway?

    Also, if I do this, any and all DHCP is no longer available for those times when I’m gone walk about with my computer. Isn’t there some sort of “situation manager” that will enable, disable, configure and change settings based on some name token that identifies where I’m trying to do networking?

    Nice article. Clearly written.
    ~~~ 0;-Dan

    [Reply]

  8. Can someone help with the following please :

    Set up LAMP sever on ubuntu 11.04 . Localhost gives home page with no problems
    Altered the server /etc/network/interfaces file to show
    auto lo
    iface lo inet loopback

    auto eth0
    iface eth0 inet static
    address 192.168.0.5
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    gateway 192.168.0.1

    Performed sudo /etc/init.d/networking restart

    Configured my Sky router so that port forwarding HTTP port 80 sends to ip address 192.168.0.5

    Then checked to see if could connect from internet using a tool on http://www.dyndns.com/support/tools/openport.html and input the ip address showing on my ADSL port ip address. Results give “An attempted connection to 94.0.47.254:80 was refused. This typically indicates that there are no services available on that port, but that it is NOT being blocked by a firewall or your ISP”

    What have i done wrong ?

    [Reply]

Leave a comment

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