Creating an Irc Bouncer With Docker and Znc

Table of Contents

Preface

This is a half ass post on setting up ZNC to be your IRC bouncer and enable automatic login for nickserv required servers. Everything is going to be done through docker.

You'll need a public facing server and about 15 minutes of time.

Dependencies

sudo apt install docker docker-io
sudo systemctl enable --now docker

Creating the container

The first command creates an interactive ZNC container that's used to generate the configuration files. You'll be prompted to set a port (i.e 8080), nickname, password, identifier for nickserv, etc. After answering the prompts select the option to not start the server.

docker run -it -v znc-cfg:/znc-data znc --makeconf

Now that the configuration files are created and your user account is setup, start the ZNC container for real this time.

docker run --name znc -d --restart always -p 8080:8080 -v znc-cfg:/znc-data znc

Logging into the web interface

With the username and password you setup earlier, log into the web interface for the ZNC instance using <ip_address>:8080. You don't have to do anything in here. There are some plugins that you can enable for fail2ban, but thats optional.

Connecting to the bouncer

With Hexchat, you can connect to it using these credentials

  Server: <YOUR_ZNC_IP>:8080
  Username: <YOUR_ZNC_USER>/<IRC_NETWORK_NAME>
  Password: <YOUR_VNC_USER>/<IRC_NETWORK_NAME>:<YOUR_ZNC_PASSWORD>
  Login Method: Server Password (/PASS password)
  SSL: Enabled

  Example:
  Username: johndoe/pine64
  Password: johndoe/pine64:super_password

Dealing with Nickserv

The only problem with the current configuration is that if the IRC server mandates nickserv registration, none of your IRC chats will be logged and you'll have to manually log into nickserv after connecting to the bouncer.

The solution is to enable the nickserv module in ZNC, connect to the bouncer, then set your nickserv credentials using a fancy command.

First stop the docker container and edit the ZNC configuration file. In the "<network>" block for your IRC SERVER, add the LoadModule = nickserv line to it

  docker container stop znc
  vim /var/lib/docker/volumes/znc-cfg/_data/configs/znc.conf

  [...]
  <Network pine64>
    FloodBurst = 9
    FloodRate = 2.00
    IRCConnectEnabled = true
    JoinDelay = 0
    LoadModule = simple_away
    LoadModule = nickserv
    Server = irc.pine64.org +6697
    TrustAllCerts = false
    TrustPKI = true
    <Chan #pine64>
    </Chan>

    <Chan #pinebook>
    </Chan>

    <Chan #pinephone>
    </Chan>
  </Network>
  [...]

Now start the container again

docker container start znc

When the container starts back up, log into your znc irc server and run this command once you're connected to the server.

  /msg *nickserv set <YOUR_SUPER_SECRET_PASSWORD>

That's all you have to do. Now your nickserv identity will automatically be verified when loggin into the ZNC server.

Listen on HTTP and HTTPS

Edit /var/lib/docker/volumes/znc-cfg/_data/configs/znc.conf

Add a new directive for another listener. It should look like this

  <Listener listener0>
        AllowIRC = true
        AllowWeb = true
        IPv4 = true
        IPv6 = true
        Port = 8080
        SSL = true
        URIPrefix = /
</Listener>

<Listener listener1>
        AllowIRC = true
        AllowWeb = false
        IPv4 = true
        IPv6 = true
        Port = 8081
        SSL = false
        URIPrefix = /
</Listener>

Now recreate your docker container with some additional port forwarding.

docker run --name znc -d --restart always -p 8080:8080 -p 8081:8081 -v znc-cfg:/znc-data znc