Open Computers 2 – Networking Part 1: DHCP

This is part of a short series of Open Computers 2 tutorials about setting up a basic network in your Minecraft world. Part 1 will you get setup with a bare minimum network allowing your computers to talk to each other. Its perfect if you plan on only having a few computers. Later parts will contain tutorials about more advanced topics such as DNS and possibly routing if I have the time.

This tutorial is fairly long as I also try to explain some of the underlying concepts so feel free to skip ahead if you are already familiar and just want to know the settings to get the network setup.

Note: This tutorial assumes you are already familiar the basics of the Linux command line. You should know cat, cd, ls and how to use a text editor such as vi.

What is a DHCP server?

The network we are going to be building is going to be very similar to the network you use at home. Each device on your home network has an IP address which is a set of 4 numbers separated by bots and looks like this “”. You can think of this like a street address for computers, this is how they know who they are sending a message to.

When a new computer joins a new network it doesn’t have an IP address, this is where the DHCP server steps in. When a new device connects to your home network it will broadcast a message to everyone asking for a DHCP server. The DHCP server (Usually running on your home router) will say “Here I am!” and then send everything the new computer needs to access the network including an IP address.

Physical Setup

This is how I have setup my physical network, the exact way does not matter as long as you have 2 new computers connected via network cables.

The left computer I am going to setup as a DHCP Server, the computer on the right will be setup with a DHCP client (all computers on our network will have a DHCP client unless its the DHCP server).

DHCP Server

There is a script included with Open Computers 2 called setup-network.lua that makes this easy, but for the sake of the tutorial we are going to do this manually since the script can mess up configs if run multiple times. It also makes it easier to change your network if you understand whats going on behind the scenes.

This is the IP range we are going to use for our local network:

  • –

Any IP address in between these will be valid for our local network, for example the below IP addresses are all valid. Any other IP addresses are considered outside the local network.


We need to do 2 things to get our DHCP server setup, we need to configure the network interface (The physical network card) and second is configure the DHCP server itself. Afterwards we will setup a client and test to make sure everything works.

Network Interface for the server

At this point you should install a “Network Interface Card” on your computer as below.
We are going to give this card a manual IP address since this will be the DHCP server. Setting up the Network Interface card will allow the DHCP server to talk to the network (Although there’s nothing to talk to just yet).

You can check to make sure the this card is visible to the computer with the below command.

ip link

This will give a lot of information, most of this not important and you can ignore it. The important part is the number and the name after it. The first is “1: lo” which we don’t need worry about and can ignore, this is for when the computer decides to talk to itself. The important one here is “2: eth0” this is our network interface card. You may need to reboot your computer if “2: eth0” does not appear.

To change the settings for this card we need to edit “/etc/network/interfaces” which can be done with the command below.

vi /etc/network/interfaces

You will notice that the “lo” interface is already setup, we need to setup the “eth0” interface, add the following lines underneath.

auto eth0
iface eth0 inet static

Your /etc/network/interfaces file should now look like the one below, changes are highlighted.

A quick explanation of what is going on here:

  • “auto eth0” means this interface is turned on when the system boots
  • “iface eth0 inet static” static means that we are not going to use DHCP to get an IP address on this computer (its the DHCP server), we are setting it up manually
  • “address” is the IP address we are manually giving to this computer
  • “netmask” this tells the computer which IP addresses are outside the network, this is not important to understand at the moment.

These settings will take effect once you reboot your computer. You can check these settings are working with the command below.


The “eth0” interface should be visible here along with the IP address it is using ( If “eth0” is missing or the IP address is not you should check your “config”/etc/network/interfaces file is correct, give your computer a reboot and check again.

DHCP Server Settings

This next part is a bit simpler, we are now going to create the config file for the DHCP server. The program that we will use as a DHCP server program is called dnsmasq and comes preinstalled.

The config file for dnsmasq “/etc/dnsmasq.conf” does not exist until you create it, you can do this with the command below:

vi /etc/dnsmasq.conf

These are the lines you need to add to the configuration:


First line has a few bits of information and each value is separated with a ” , “.

  • The first and second values “ ,” are the lease range, IP addresses given to clients will be between these two values. Although all addresses from to are valid, we only want some of these addresses to be used for DHCP. In some cases we will need or want a static IP for some machines. A good example of this is the DHCP server itself. This setting leaves some space for those static machines.
  • The third value “” is not important to understand at the moment, it had the same function as it does in the interfaces file.
  • The fourth value is how long the lease (The IP address given to the clients) stays valid for. The exact value here isn’t super important for us atm. But its needed to make sure computers don’t keep a lease even if they’re long gone/disconnected.
    Clients will automatically contact dnsmasq (the DHCP server) again to renew their IP address lease before this timer runs out.

The second line “dhcp-authoritative” is not required, but can speed up clients receiving an IP address lease.

Your “/etc/dnsmasq.conf” file should appear as below

Fortunately for us we don’t need to do anything fancy to start the dnsmasq program, it should attempt to start on boot as long as the config file exists so all we need to do is reboot the computer.

If everything went well you should see that “OK” just before the login prompt after a reboot, see below:

If dnsmasq is not listed, that means it did not start, make sure you created the config file in the correct location (the /etc folder). If you see an error here instead such as “Bad option” or similar, double check your spelling in the config file.

This DHCP server is now setup and we can move on to setting up our client computer.

DHCP Clients

All the hard work setting up the DHCP server is about to pay off. Setting up clients is really simple since the server is going to take care of the hard work for us. We are now setting up the right computer (Standard Computer) from the physical setup screenshot.

First you need to add a “Network Interface Card” just like the server, however this time we are going to set the interface config to use DHCP instead of static.

Open the “/etc/network/interface” file and add the following lines:

auto eth0
iface eth0 inet dhcp

Save the file and give the computer a reboot. This should be all we need to do to setup the client.

During the boot up sequence the client computer is going to broadcast, looking for a DHCP server, then our DHCP server is going to respond and provide network setup details. You should be able to see this process similar to below:

udhcpc is the program that is automatically being used as a DHCP client the “” is the clients new IP address. If you see something similar to this everything should be working. If udhcpc does not appear at all during reboot, double check your clients “/etc/network/interfaces” file, if you receive a “Timeout” error, then there is either a connection issue or an issue with the DHCP server.

The IP address your client is given will very likely be different from mine, the exact number could be anything in the range we set in “/etc/dnsmasq.conf/” on the DHCP server

You should also now be able to other computers on the network. Here I setup a second client and used the ping command to confirm it was connected properly to my first client.

Here’s a diagram of how my network looks after adding the second client, keep in mind the hub at the top doesn’t do anything special, just connects everything together.

DHCP Setup complete

What we have just setup is what the included ./setup-network.lua script does and you will probably want to use it from now on to speed up setting up your network. However you now know how it works and are better equipped to fix any network issues that may appear.

Now that your computers have IP addresses you can now make them talk to each with different programs and scripts. The next tutorial will cover the modification you need to make if you want to setup DNS on your network.

DNS will let you use names instead of an IP address and are much easier to remember.