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.
- 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 install tightvncserver
> cd .config
> mkdir autostart
> cd autostart
> leafpad tightvnc.desktop
- Next, we will start Tight VNC on port number 1. You will be prompted to set a password.
- Finally, we will configure Pi to auto-start Tight VNC upon startup.
> 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.
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.
- Install Lua, the default scripting language of PtokaX
- Download, extract, and build PtokaX
> tar -xf 0.5.2.1-nix-src.tgz
> cd PtokaX
> make lua52
- To run, simply run:
- 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.
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
Post a Comment