Sat 26 August 2017

Setting up an IRC bouncer (ZNC) on Amazon AWS and connecting to it using Irssi

Posted by ankur in Tech (798 words, approximately a 4 minute read)

Given how important a collaborative tool the IRC is for us free software enthusiasts, it is imperative that one be accessible on various networks as much as possible. Personally, I used to leave my system at the laboratory logged in all the time, but then I'd have to VPN into the university and then SSH into my system there. Not ideal, really.

The commonest way of always remaining connected to the IRC is to use an IRC bouncer. The bouncer remains connected to one's networks all the time, and one can use a client from wherever to connect to the networks via this bouncer. There are a few free to use bouncers that one can use, of course. On preliminary investigation though, it didn't seem too hard to set a private instance up, so I gave it a go.

Amazon AWS set up

The bouncer must be deployed on a system that is accessible from anywhere to be truly useful. While I do have hosting for this blog, it's cheap shared hosting without shell access. So, I needed another machine. Some research led me to the free tier on Amazon AWS where one can get a free AWS instance for 12 months. The process is very well documented, so I won't clone it here. There are various Linux operating systems that one can choose from. Being a Fedora user, I opted for Red Hat Enterprise Linux, but any Linux would work.

After the AWS instance is up and running, one must follow the instructions in the documentation to enable SSH access to it. It requires setting up security rules using the web console.

ZNC set up

There are a few bouncers available. I chose the popular ZNC bouncer.

On a Red Hat system, ZNC is available in the "extra packages" repositories. So, it comes down to a few commands:

sudo yum install
sudo yum install znc

This will install the ZNC package. ZNC provides a simple way of configuring it too:

sudo znc --makeconfig

Of course, one must make sure that the service is always running:

sudo systemctl enable znc.service
sudo systemctl start znc.service

During the configuration, one must note what port ZNC was set up to listen to, and what the public IP of the AWS machine is. These are required to set up the IRC client later, in this case Irssi. One must also remember to open this port to inbound connections. This can be done using the AWS web console in the same way as the SSH port was enabled earlier. Please refer to the relevant bits in the AWS documentation. ZNC can be further configured through the web administration interface. One can add more networks, channels, and useful ZNC modules there.

Browsers seem to ban connecting to a few ports that are deemed dangerous. I found this to be the case on Firefox, Chrome, and Qutebrowser. Instructions on how to workaround this ban are here for Firefox and Chrome respectively. I couldn't figure out how this needs to be done for Qutebrowser and I've filed an issue here. It seems to be an upstream QT issue that is already being looked into.

Irssi set up

Once the bouncer has been deployed correctly, all that remains is to configure an IRC client to connect to it. I use Irssi myself so the steps documented here will be specific to it. However, they should be general enough to be applicable to other clients too.

Installing Irssi on a Fedora system is trivial, of course:

sudo dnf install Fedora # node that Fedora uses DNF now

Irssi reads its configuration file from ~/.irssi/config. There are commands to configure servers, and these write to the configuration file that has quite a simple structure and can be edited directly using a text editor. The relevant snippets from my configuration file are below. Here, because we're connecting to our IRC servers via the bouncer, the address in use will be that of the bouncer. The ZNC web administration interface informs on what the password should be.

servers = (
    address = "<public address of the AWS instance";
    chatnet = "freenode";
    port = "<port ZNC is listening to>";
    password = "<ZNC username/network1:password>";
    use_tls = "yes";
    tls_verify = "no";
    autoconnect = "yes";
    address = "<public address of the AWS instance";
    chatnet = "slack";
    port = "port ZNC is listening to";
    password = "<ZNC username/network2:password>";
    use_tls = "yes";
    tls_verify = "no";
    autoconnect = "yes";

Irssi can also be customised to suit the user - such as the window layout, plug-ins, theme. I won't document how here. Instead I refer to the Irssi documentation.


That's quite it. The bouncer will always run, and wherever one is, one can use a client to keep up with happenings. I hope this post will make it easier for others to set up their private bouncers too. Comments, and feedback are always welcome. Cheers!