Configure Static IP Address in Ubuntu Server 8.10

Status
Not open for further replies.

Osiris

Golden Master
Messages
36,817
Location
Kentucky
Source: 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
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
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
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
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.
DNS
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:
nameserver 208.67.220.220
nameserver 208.67.222.222
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.)
Final Thoughts
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.
 
Status
Not open for further replies.
Back
Top Bottom