Configure Static IP Address in Ubuntu Server 8.10
If you have a need for a server OS that is robust, reliable, and as flexible as any other server available, then Ubuntu 8.10 should be in serious consideration. There is only one drawback to this server - no GUI. Oh sure you could install a GUI (you'd be doing it from the command line of course), but that would defeat the purpose of having a headless server that is going to suffer from serious loneliness as it sits alone doing its job.
Naturally if you have such a server, you have to have the ability to configure that server. One of the configurations you most likely will need to undertake is the configuring of network settings for a static IP address on your headless, GUI-less server. Fortunately, when using Ubuntu Server 8.10 - that is a piece of cake.
In reality there are two files that must be configured and one file that can be configured. The "must files" are /etc/network/interfaces and /etc/resolv.conf. The "can file" is /etc/hosts. We will deal with the former two files in this article. The latter file (a file that deals with local IP to name mapping) has already been covered in my article "Ease Linux Networking with /etc/hosts" here on gHacks.
So let's first take a look at the most important file, /etc/network/interfaces. Open that file up in your favorite editor (mine being nano).? What you will most likely see is this:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
iface lo inet loopback
# The primary network interface
iface eth0 inet dhcp
The last line is what you need to edit (and add to.) To configure eth0 (your network device) for a static IP address that last line should resemble:
iface eth0 inet static
Naturally you will need to change the last three lines to reflect your own networking setup.
Once that file has been edited you can restart your network connection with the command:
sudo /etc/init.d/networking restart
Your Ubuntu Server 8.10 should now be up and running with a static IP address.
There is one last file you will need to take care of. That file is /etc/resolv.conf. This file is in charge of holding your DNS server addresses. Open this file up in your editor. What you need are two lines:
The above example reflects using the OpenDNS servers. Your network will obviously have its own requirements for DNS addresses. Once you have edited that file save it and you're done (no need to restart networking for the change in DNS addresses to take effect.)
That's it. How simple is it to configure your Ubuntu Server with a static IP address - even when said server is a headless, GUI-less server. Of course there is much more you can do than simple Static IP address configuration, but this just highlights how easy a Linux server can actually be to administer.Advertisement
Very good, thanks for the info.
great tip, thanks!
so why not do a complete install/setup-configure/test static ip webserver with a dummy website serving mysql dynamic content. Using one of the lattest distro eg. ubuntu / opensuse with diagrams.
you’ll help lots of people and if you have a [donate] click i am sure people will send generously when they finally find something that works.
if i knew how to do it i would explain it to the world with diagrams from the very geginning – eg. what directories contain what files and what these files are used for etc.
thanks and good luck.
Thanks! Why didn’t I switch to static local IP earlier when it was this easy? … I suppose I thought it would be hard as I had trouble with Fedora (10).
What do I put in place of nameserver?
Or is it in my case
to be added to my resolv.conf