How to turn an Ubuntu desktop into a convenient Linux-based server

If you have a desktop computer and a laptop chances are that, in the long run, you end up spending more time working on your laptop than on your desktop. If repurposing your old desktop into a fully fledged server seems like too much of a commitment (either because you do not have the time to set it up or do not want to give up your desktop), you can still configure it as to offer services to other computers on your network without having to go for a server operating system.

Accessing a computer from your local network usually just means assigning an static IP address to your desktop and have it though that IP address every time. The peculiarity with desktop Linux distributions -such as Ubuntu or Fedora- is that they now ship with an utility called NetworkManager which tries to make it “simple” to manage networks. The problem with NetworkManager is that, in my opinion, it was designed mostly for a mobile scenario, where a laptop moves around and tries to join different networks along the way, but this is rarely the case for a desktop computer, which just connects to the same network every time. Furthermore, depending on your router configuration, it may prove difficult to impossible to have a NetworkManager-enabled desktop PC to have the same IP address assigned every time the computer joins the DHCP network.

In this post we will present a method for completely disabling NetworkManager from your Ubuntu desktop system and, using the old-school Linux networking facilities, have your desktop computer’s network connection set up your way, offering services to other computer without sacrificing Internet access.

This article has been tested on Ubuntu 8.04.

Step 1 – Disabling NetworkManager

NetworkManager handles all network connections, preventing us from manually configuring our host the way we want to. The first step to take consists in disabling NetworkManager once and for all. We use the following Terminal commands (as root):

sudo service NetworkManager stop

sudo rm find /etc/rc* -name “*NetworkManager”

The first command stops NetworkManager, whereas the second one removes every NetworkManager entry from the Linux runlevels, effectively preventing it from automatically starting the next time the system is started.

Although it is not strictly necessary, it would be “elegant” to remove the GNOME NetworkManager applet from the desktop environment as well. This can be disabled from the “System -> Preferences -> Sessions” configuration panel just by unchecking the corresponding entry. This will prevent the applet from automatically staring the next time we log in. If we wanted to stop the currently executing applet without having to logout and log in again, we could stop the “nm-applet” or “nm-gnome-applet” process from the Terminal using the kill command.

Step 2 – Configuring our Network Interface

Without NetworkManager in the way, we can define and configure our Network Interface the way we want to. We just need to edit the /etc/network/interfaces file and add the following configuration. We will name our interface “eth0″ and assign an IP address of “192.168.1.50/24″, but you can set the interface to any values you desire. This has to be done as root.

auto eth0

iface eth0 inet static

address 192.168.1.50

netmask 255.255.255.0

broadcast 192.168.1.255

gateway 192.168.1.1

The first line is of special importance. It declares eth0 as an interface that has to be enabled automatically when the system is booting. Now we must set the DNS servers this host will use for resolving domain names. In order to set this servers, we must edit the file: /etc/resolv.conf (again as root) and we add the following lines (this is Uruguay-specific):

nameserver 200.40.30.245

nameserver 200.40.220.254

Once the changes have been written to disk, we can restart the network in order to make sure our changes were correct:

sudo service networking restart

Having restarted the host’s network configuration, we can verify the active interfaces using the “ifconfig” command. If our changes were correct, we should now be connected to the network, being able to browse the Internet without difficulties and with an static IP address of 192.168.1.50.