[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

Linux-tips

Fork me on GitHub

I. Linux tips

11. Setting up an IRC bouncer

In here, I'll explain how to install an IRC bouncer (znc to be precise). Let's go!

Getting pieces

First, install znc (I'll use apt in this tutorial):

# try this line first:
sudo apt-get install znc znc-extra
# if you have an error about znc-extra, then try this one:
sudo apt-get install znc

If everything in here went fine, then great!

Setting up

Now that you have znc, you need to configure it. To make things easier, I'll comment each step:

> znc --makeconf
[ .. ] Checking for list of available modules...
[ >> ] ok
[ ** ] Building new config
[ ** ]
[ ** ] First let's start with some global settings...
[ ** ]
[ ?? ] What port would you like ZNC to listen on? (1025 to 65535): 3333

In here, you need to pick a port on which your bouncer will listen (it doesn't have to match the irc servers you want to connect to). I chose 3333.

[ ?? ] Would you like ZNC to listen using SSL? (yes/no) [no]: yes

For security reasons, I enabled SSL.

[ ?? ] Would you like ZNC to listen using both IPv4 and IPv6? (yes/no) [yes]:

Doesn't matter so I used yes.

[ .. ] Verifying the listener...
[ >> ] ok
[ ** ]
[ ** ] -- Global Modules --
[ ** ]
[ ** ] +-----------+----------------------------------------------------------+
[ ** ] | Name      | Description                                              |
[ ** ] +-----------+----------------------------------------------------------+
[ ** ] | partyline | Internal channels and queries for users connected to znc |
[ ** ] | webadmin  | Web based administration module                          |
[ ** ] +-----------+----------------------------------------------------------+
[ ** ] And 13 other (uncommon) modules. You can enable those later.
[ ** ]

This part is about the modules. I'll let you choose yourself and just put what I chose.

[ ?? ] Load global module <partyline>? (yes/no) [no]: yes
[ ?? ] Load global module <webadmin>? (yes/no) [no]:
[ ** ]

The interesting part is now starting. You need to setup the user that'll be used to connect to your bouncer:

[ ** ] Now we need to set up a user...
[ ** ]
[ ?? ] Username (AlphaNumeric): imperio
[ ?? ] Enter Password:
[ ?? ] Confirm Password:
[ ?? ] Would you like this user to be an admin? (yes/no) [yes]:
[ ?? ] Nick [imperio]:
[ ?? ] Alt Nick [imperio_]:
[ ?? ] Ident [imperio]:
[ ?? ] Real Name [Got ZNC?]:

So until this point, just basic information. Try to not mess with them! The following options aren't that useful so you can keep default values, it won't have much impact...

[ ?? ] Bind Host (optional):
[ ?? ] Number of lines to buffer per channel [50]: 1000
[ ?? ] Would you like to clear channel buffers after replay? (yes/no) [yes]: no
[ ?? ] Default channel modes [+stn]:
[ ** ]

We're now back in the modules, but on the user's side now:

[ ** ] -- User Modules --
[ ** ]
[ ** ] +--------------+------------------------------------------------------------------------------------------+
[ ** ] | Name         | Description                                                                              |
[ ** ] +--------------+------------------------------------------------------------------------------------------+
[ ** ] | chansaver    | Keep config up-to-date when user joins/parts                                             |
[ ** ] | controlpanel | Dynamic configuration through IRC. Allows editing only yourself if you're not ZNC admin. |
[ ** ] | perform      | Keeps a list of commands to be executed when ZNC connects to IRC.                        |
[ ** ] | webadmin     | Web based administration module                                                          |
[ ** ] +--------------+------------------------------------------------------------------------------------------+
[ ** ] And 21 other (uncommon) modules. You can enable those later.
[ ** ]
[ ?? ] Load module <chansaver>? (yes/no) [no]: yes
[ ?? ] Load module <controlpanel>? (yes/no) [no]:
[ ?? ] Load module <perform>? (yes/no) [no]: yes
[ ?? ] Load module <webadmin>? (yes/no) [no]:
[ ** ]

The next part is very important. You'll now fulfill the IRC server(s) on which you want your bouncer to connect to. Do it very carefully!

[ ?? ] Would you like to set up a network? (yes/no) [no]: yes

So obviously you answered yes. Now the next thing is simple: if you want to connect to freenode, put freenode, otherwise put efnet.

[ ?? ] Network (e.g. `freenode' or `efnet'): efnet
[ ** ]

Other modules, but for network this time.

[ ** ] -- Network Modules --
[ ** ]
[ ** ] +-------------+-------------------------------------------------------------------------------------------------+
[ ** ] | Name        | Description                                                                                     |
[ ** ] +-------------+-------------------------------------------------------------------------------------------------+
[ ** ] | chansaver   | Keep config up-to-date when user joins/parts                                                    |
[ ** ] | keepnick    | Keep trying for your primary nick                                                               |
[ ** ] | kickrejoin  | Autorejoin on kick                                                                              |
[ ** ] | nickserv    | Auths you with NickServ                                                                         |
[ ** ] | perform     | Keeps a list of commands to be executed when ZNC connects to IRC.                               |
[ ** ] | simple_away | This module will automatically set you away on IRC while you are disconnected from the bouncer. |
[ ** ] +-------------+-------------------------------------------------------------------------------------------------+
[ ** ] And 20 other (uncommon) modules. You can enable those later.
[ ** ]
[ ?? ] Load module <chansaver>? (yes/no) [no]: yes
[ ?? ] Load module <keepnick>? (yes/no) [no]: yes
[ ?? ] Load module <kickrejoin>? (yes/no) [no]: yes
[ ?? ] Load module <nickserv>? (yes/no) [no]:
[ ?? ] Load module <perform>? (yes/no) [no]: yes
[ ?? ] Load module <simple_away>? (yes/no) [no]: yes
[ ** ]

We're now going into the interesting stuff: setting up the IRC servers we want to connect to:

[ ** ] -- IRC Servers --
[ ** ] Only add servers from the same IRC network.
[ ** ] If a server from the list can't be reached, another server will be used.
[ ** ]
[ ?? ] IRC server (host only): irc.mozilla.org
[ ?? ] [irc.mozilla.org] Port (1 to 65535) [6667]:
[ ?? ] [irc.mozilla.org] Password (probably empty):
[ ?? ] Does this server use SSL? (yes/no) [no]:
[ ** ]
[ ?? ] Would you like to add another server for this IRC network? (yes/no) [no]:
[ ** ]
[ ** ] -- Channels --
[ ** ]
[ ?? ] Would you like to add a channel for ZNC to automatically join? (yes/no) [yes]: #rust-docs
[ ?? ] Would you like to add a channel for ZNC to automatically join? (yes/no) [yes]:
[ ?? ] Channel name: #rust-docs
[ ?? ] Would you like to add another channel? (yes/no) [no]: yes
[ ?? ] Channel name: #rust-fr
[ ?? ] Would you like to add another channel? (yes/no) [no]: yes
[ ?? ] Channel name: #rust-internals
[ ?? ] Would you like to add another channel? (yes/no) [no]: yes
[ ?? ] Channel name: #servo
[ ?? ] Would you like to add another channel? (yes/no) [no]: yes
[ ?? ] Channel name: #winapi
[ ?? ] Would you like to add another channel? (yes/no) [no]: yes
[ ?? ] Channel name: #hyper
[ ?? ] Would you like to add another channel? (yes/no) [no]:
[ ?? ] Would you like to set up another network? (yes/no) [no]:
[ ** ]
[ ?? ] Would you like to set up another user? (yes/no) [no]:
[ .. ] Writing config [/home/pi/.znc/configs/znc.conf]...
[ !! ] This config already exists.
[ ?? ] Would you like to overwrite it? (yes/no) [no]: yes
[ .. ] Overwriting config [/home/pi/.znc/configs/znc.conf]...
[ >> ] ok
[ ** ]
[ ** ]To connect to this ZNC you need to connect to it as your IRC server
[ ** ]using the port that you supplied.  You have to supply your login info
[ ** ]as the IRC server password like this: user/network:pass.
[ ** ]
[ ** ]Try something like this in your IRC client...
[ ** ]/server <znc_server_ip> +3333 imperio:<pass>
[ ** ]And this in your browser...
[ ** ]https://<znc_server_ip>:3333/
[ ** ]
[ ?? ] Launch ZNC now? (yes/no) [yes]:
[ .. ] Opening config [/home/pi/.znc/configs/znc.conf]...
[ >> ] ok
[ .. ] Loading global module [partyline]...
[ >> ] [/usr/lib/znc/partyline.so]
[ .. ] Binding to port [+3333]...
[ >> ] ok
[ ** ] Loading user [imperio]
[ ** ] Loading network [efnet]
[ .. ] Loading network module [chansaver]...
[ >> ] [/usr/lib/znc/chansaver.so]
[ .. ] Loading network module [keepnick]...
[ >> ] [/usr/lib/znc/keepnick.so]
[ .. ] Loading network module [kickrejoin]...
[ >> ] [/usr/lib/znc/kickrejoin.so]
[ .. ] Loading network module [perform]...
[ >> ] [/usr/lib/znc/perform.so]
[ .. ] Loading network module [simple_away]...
[ >> ] [/usr/lib/znc/simple_away.so]
[ .. ] Adding server [irc.mozilla.org 6667 ]...
[ >> ] ok
[ .. ] Loading user module [chansaver]...
[ >> ] [/usr/lib/znc/chansaver.so]
[ .. ] Loading user module [perform]...
[ >> ] [/usr/lib/znc/perform.so]
[ .. ] Forking into the background...
[ >> ] [pid: 2648]
[ ** ] ZNC 1.4 - http://znc.in

And that's mostly all.

Connecting to the bouncer

To connect to you bouncer, you'll need to do a few things in your IRC client:

  • Enable SSL.
  • Accept invalid SSL certificate.
  • Set server password.

For the last point, it has to follow a precise format. So in my case, my bouncer user is imperio, I chose the efnet network (since I'm not connecting to freenode) and then I chose poney as password. So my server password will have to be:

imperio/efnet:poney

Simple!

Accessing to the bouncer from outside

If your bouncer has been set in a local network, I guess you want to make it accessible from outside? The only way to do it is to open a port from your internet box provider. I'll let you look into it.

znc commands

A few commands from znc can be useful like:

  • znc --makepass: to reset the bouncer user password.
  • znc --makeconf: to generate a config file (or overwrite it) interactively.

It's important to note that the configuration of your znc bouncer is generally located into ~/.znc/configs/znc.conf. Try to not mess this file!

Automatic startup

In case you want to have znc to start when you boot and you lost the config file, here it is:

[Unit]
Description=ZNC - IRC Bouncer
Requires=nss-user-lookup.target
After=network-online.target nss-user-lookup.target

[Service]
User=pi
ExecStart=/usr/bin/znc --foreground
Restart=on-failure
KillSignal=SIGINT

[Install]
WantedBy=multi-user.target

Put it into /etc/systemd/system/znc.service, then:

sudo systemctl enable znc
sudo systemctl start znc