PHPKB Knowledge Base Software Logo  
Guru Corner
Online Knowledgebase System  
Knowledge Base Home Knowledge Base Home
Home > All Categories > Linux > Ubuntu > Change Ubuntu Server from DHCP to a Static IP Address
Question Title Change Ubuntu Server from DHCP to a Static IP Address

If the Ubuntu Server installer has set your server to use DHCP, you will want to change it to a static IP address so that people can actually use it.

Changing this setting without a GUI will require some text editing, but thatís classic Linux, right?

Letís open up the /etc/network/interfaces file. Iím going to use nano, but you can choose a different editor

sudo nano /etc/network/interfaces

For the primary interface, which is usually eth0, you will see these 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 be added below it. Obviously youíd customize this to your network.

auto eth0
iface eth0 inet static
       dns-search domain.local

Now weíll just need to restart the networking components:

sudo /etc/init.d/networking restart

If setting the DNS does not work in the Interfaces then try the suggestion below:

Keep it mind that Ubuntu appends a tail file to the resolv.conf file that it generates.

Try this:

sudo nano /etc/resolvconf/resolv.conf.d/tail

Which will open a blank resolv.conf.d file in the nano text editor. You will need to place your DNS server address on the first line of this file and remember to end the line with a carriage return (hit enter) as seen below:


Editing the tail file instead of the actual resolv.conf file will prevent your change from being lost upon a system reboot.

You will need to run sudo resolvconf -u to activate the change. You should be able to ping after this.

Authored by: Guru Corner
Click Here to View all the questions in Ubuntu category.
File Attachments File Attachments
There are no attachment file(s) related to this question.
Article Information Additional Information
Article Number: 314
Created: 2013-09-14 5:56 PM
Rating: No Rating
Article Options Article Options
Print Question Print this Question
Export to Adobe PDF Export to PDF File
Export to MS Word Export to MS Word
Search Knowledge Base Search Knowledge Base

Powered by Guru Corner