Skip to main content

Setting up DC Hub on Raspberry Pi

Aditya Pal came to my room to check out a Raspberry Pi that I had recently received as a gift. I told him it was a small, credit-card-sized computer. It powers on as soon as you plug it in and boots up quickly. I was already using it as a server for other purposes (hosting BitTorrent).

Our hostel at college had a strange network issue. The intra-hostel network worked smoothly. However, we faced a lot of issues outside of the hostel (especially at Hostel 7, which was disconnected from the external network for a month). The college's official Domain Controller (DC) was on the external network and was inaccessible for quite some time whenever we faced network issues.

Aditya suggested the idea of setting up a DC on a Raspberry Pi for the students of the hostel. We worked together for a few days to finally set up a DC on a Raspberry Pi running Raspbian. It remained active for over a year until the college administration finally decided to shut it down due to network congestion. There were already four active hubs drawing significant traffic.

In this article, I will outline the steps to set up a DC hub on a Raspberry Pi. I will only provide you with abstract steps without delving into details. I assume that you are already well-versed in Linux (Debian distribution), VNC, and networking concepts.

How To?

Step 1: Install NOOBS operating system (Optional)

If you already have an operating system installed on your Raspberry Pi, then you can skip this step. There are many operating systems available for Raspberry Pi. I recommend NOOBS or Raspbian as good choices for beginners. Head over to https://www.raspberrypi.org/downloads/ and install your preferred operating system by following the steps provided. Installing an operating system on a system without any I/O devices is a lengthy and complex process. To get started easily, it's best to have an external monitor and a USB keyboard and mouse connected to your Raspberry Pi until the operating system is installed.

Step 2: Set up VNC Server (Optional)

Once you have installed an operating system, it is recommended to install a VNC server on Raspberry Pi. VNC server would let you access a system remotely. You no longer need to connect an external monitor or input devices. Tight VNC is a popular implementation of VNC that is available for Raspbian OS.
  • Power on Raspberry Pi and connect your computer to Raspberry Pi via Ethernet. Your PC will allocate a dynamic IP to Raspberry Pi.

  • Share your Internet with the Ethernet. This will allow Raspberry Pi to access the Internet.

  • Issue an address resolution using your terminal. You will get the dynamic IP address of Raspberry Pi.
         > arp -a
  • Use SSH to log in remotely to Raspberry Pi.

  • Once logged in, we can install Tight VNC. Run the following command in the SSH session to install Tight VNC.
                   > sudo apt-get update
        > sudo apt-get install tightvncserver
  • Next, we will start Tight VNC on port number 1. You will be prompted to set a password.
        > vncserver :1
  • Finally, we will configure Pi to auto-start Tight VNC upon startup.
        > cd /home/pi
        > cd .config
        > mkdir autostart
        > cd autostart
        > leafpad tightvnc.desktop

          Add the following to Leafpad and save and exit. VNC will autostart from the next boot.

        [Desktop Entry]
        Type=Application
        Name=TightVNC
        Exec=vncserver :1
        StartupNotify=false
  • Use a VNC viewer (e.g. Real VNC) on your PC to log in to Pi on port 1.

Step 3: Set up static IP (Optional)

We don't want the hub to change its address whenever the Pi starts up. Therefore, we will be setting up a static IP for it. Open /etc/dhcpcd.conf on the Pi and add the following to the end:

interface eth0
static ip_address=<IP>/<subnet>
static routers=<Router address>
static domain_name_servers=<Nameserver address>

Step 4: Install PtokaX

PtokaX is a popular Direct Connect Hub. Here we will be installing PtokaX 0.5.2.1. You can check the latest distribution from the website http://www.ptokax.org/downloads.html.
  • Install the necessary build tools.
       > sudo apt-get install make g++ zlib1g-dev libtinyxml-dev
  • Install Lua, the default scripting language of PtokaX
       > sudo apt-get install liblua5.2-dev
  • Download, extract, and build PtokaX
       > wget http://www.PtokaX.org/files/0.5.2.1-nix-src.tgz
       > tar -xf 0.5.2.1-nix-src.tgz
       > cd PtokaX
       > make lua52
  • To run, simply run:
       > ./PtokaX -m
  • You may edit the Settings.pxt in cfg according to your needs.
  • To auto-start PtokaX on startup add the following line to rc.local inside /etc folder.
       > cd PtokaX && ./PtokaX

Conclusion

You have successfully set up your own DC Hub that can easily work day and night without stopping. I had left it running for about 5 months nonstop and faced no issues.

Comments

Popular posts from this blog

Architecture of High Performance Computing Server at BIT Mesra

A High-Performance Computing (HPC) server was installed a few years back. It was a replacement for PARAM 10000, the supercomputer that is no longer available for use. Initially, the HPC was under the Department of Computer Science. The Department of Chemical Engineering and Biotechnology was the primary user of the HPC (mostly for simulation purposes), and so the administration decided to move it under the Central Instrumentation Facility (CIF). You need permission from the CIF to access the HPC. HPC is only available for research purposes, and you need to provide a good reason along with a proper recommendation from a professor to gain access to the HPC. The HPC is at least 20 times more powerful than the most powerful PC that anyone has on campus. Also, I recently checked the usage and realized that not even 10% of its power is being utilized. I hope this blog post will help you in understanding the core architecture of the HPC. Architecture The Architecture of High Performance Compu...

Setting up Machine Learning Environment on High Performance Computing Server

In the last article, I discussed the architecture of the HPC. If you have not read that article, I would recommend that you read it before proceeding with this one. Architecture of High-Performance Computing Server at BIT Mesra  The power of HPC can be utilized for its most important application in the field of computer science: Machine Learning. I am assuming that you already have obtained your SSH credentials to log on to the master node. Also, we will be setting up the environment in Python. Let's jump straight to the steps. How To? Step 1: Download and Install Anaconda on the Master Node Note that you are not the root user of the HPC. You are just a regular user, and therefore, administrative commands (such as sudo or su) will not work. Anaconda has made it much easier to install Python packages for non-root users, and we will be using Anaconda for setting up Python 3 and installing the required packages. Log in to the master node     > ssh be1005815@172.16.23.1 Go...