How to build your own IRC Server with InspIRCd and Anope

InspIRCd is a modern and fast IRC server and one of the few IRC server applications that provides high performance and stability and is written from scratch in C++. It's one of the best solutions to build your own IRC on your server. It supports two encryption libraries, OpenSSL and gnutls and has support for many services like anope theme. InspIRCd is based on the modular IRCd which provides many modules. If you want to enable a module on InspIRCd, you just need to edit the modules.conf file and add a new line for the module.

In this tutorial, I will guide you trough the installation of InspIRCd from source on  a CentOS 7 server. Then we will integrate InspIRCd with anope services and enable gnutls encryption on it.

Prerequisites

  • CentOS 7 server - 64bit.
  • Root privileges

Step 1 - Install Packages

In this step, we will install some RPM packages. The packages are for the module manager (based on perl) and packages for the InspIRCd installation. Log in to the server and switch to root with the sudo command:

ssh [email protected]
sudo su

Install the Perl extensions so we can use module manager later.

yum -y install perl perl-libwww-perl perl-Crypt-SSLeay perl-LWP-Protocol-https

Then install gnutls and the gcc compiler for InspIRCd installation:

yum -y install gcc-c++ gnutls gnutls-devel gnutls-utils pkgconfig wget

Step 2 - Add a new system user

We want to run InspIRCd as irc user, so we need to create a new account on the system. Add the new user with the useradd command below:

useradd -m -s /bin/bash irc

-m = create a home folder for the user.
-s = define the shell - we use the /bin/bash shell.

Step 3 - Install InspIRCd

From the root user, switch to the new account irc:

su - irc

Now we are in the home directory of the irc user, download the inpircd source code with the wget command, and extract it:

wget https://github.com/inspircd/inspircd/archive/v2.0.21.tar.gz
tar -xzvf v2.0.21.tar.gz

Go to the inspircd directory:

cd inspircd-2.0.21/

Enable the gnutls support for inspIRCd:

./configure --enable-extras=m_ssl_gnutls.cpp

And then install it, we will install InspIRCd on the home directory "":

./configure

You will be asked for the installation directory, we will use "/home/irc/inspircd/" as the installation directory. Type the complete path of the directory and press y or enter.

Build ircd

Now run:

make
make install

Wait for installation process to finish, then remove the inspircd-2 directory:

cd ~/
rm -rf inspircd-2.0.21/

Step 4 - Configure InspIRCd

If all installation is done, go to the inspircd directory.

cd inspircd/

Create a new "cert" directory for the certificate files and create new certificates with the certtool command - or you can use openssl to generate it.

mkdir cert; cd cert
certtool --generate-privkey --outfile key.pem
certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem

Now we have a certificate and key file in the cert directory:

cert.pem
key.pem

Next, go to the conf directory and create a new configuration file inspircd.conf:

cd ~/inspircd/conf/
vi inspircd.conf

Paste the configuration below:


<config format="xml">
<define name="bindip" value="1.2.2.3">
<define name="localips" value="&bindip;/24">

####### SERVER CONFIGURATION #######

<server
        name="chat.inspircd.co"
        description="Welcome to inspird World"
        id="97K"
        network="chat.inspircd.co">


####### ADMIN INFO #######

<admin
       name="jun naruse"
       nick="naruse"
       email="[email protected]">

####### PORT CONFIGURATION #######

<bind
      address=""
      port="6697"
      type="clients"
      ssl="gnutls">

<module name="m_ssl_gnutls.so">
<gnutls certfile="/home/irc/inspircd/cert/cert.pem" keyfile="/home/irc/inspircd/cert/key.pem" priority="NORMAL:-MD5" hash="sha1">

<bind
       address=""
       port="7000"
       type="servers">

####### DIE and RESTART CONFIGRATION #######

<power
       diepass="mypassword"
       restartpass="mypassword">

####### CONNECT CONFIGURATION #######

<connect deny="3ffe::0/32" reason="The 6bone address space is deprecated">

<connect
         name="main"
         allow="*"
         #maxchans="30"
         timeout="10"
         pingfreq="120"
         hardsendq="1M"
         softsendq="8192"
         recvq="8K"
         threshold="10"
         commandrate="1000"
         fakelag="on"
         localmax="10"
         globalmax="10"
         useident="no"
         limit="5000"
         modes="+x">

####### CIDR CONFIGURATION #######

<cidr
      ipv4clone="32"
      ipv6clone="128">

####### INCLUDE FILE #######

<include file="conf/opers.conf">
#<include file="conf/examples/links.conf.example">

####### MISCELLANEOUS CONFIGURATION #######

<files motd="conf/motd.txt" rules="conf/rules.txt">

####### MAXIMUM CHANNELS #######

<channels
          users="20"
          opers="60">

####### PID FILE #######

<pid file="/home/irc/inspircd/inspircd.pid">

####### BANLIST LIMITS #######

<banlist chan="#largechan" limit="128">
<banlist chan="*" limit="69">

####### SERVER OPTIONS #######

<options
         prefixquit="Quit: "
         suffixquit=""
         prefixpart="&quot;"
         suffixpart="&quot;"
         syntaxhints="no"
         cyclehosts="yes"
         cyclehostsfromuser="no"
         ircumsgprefix="no"
         announcets="yes"
         allowmismatch="no"
         defaultbind="auto"
         hostintopic="yes"
         pingwarning="15"
         serverpingfreq="60"
         defaultmodes="nt"
         moronbanner="You're banned! Email [email protected] with the ERROR line below for help."
         exemptchanops="nonick:v flood:o"
         invitebypassmodes="yes"
         nosnoticestack="no"
         welcomenotice="yes">


####### PERFORMANCE CONFIGURATION #######

<performance
             netbuffersize="10240"
             somaxconn="128"
             limitsomaxconn="true"
             softlimit="12800"
             quietbursts="yes"
             nouserdns="no">

####### SECURITY CONFIGURATION #######

<security
          announceinvites="dynamic"
          hidemodes="eI"
          hideulines="no"
          flatlinks="no"
          hidewhois=""
          hidebans="no"
          hidekills=""
          hidesplits="no"
          maxtargets="20"
          customversion=""
          operspywhois="no"
          restrictbannedusers="yes"
          genericoper="no"
          userstats="Pu">

####### LIMITS CONFIGURATION #######

<limits
        maxnick="31"
        maxchan="64"
        maxmodes="20"
        maxident="11"
        maxquit="255"
        maxtopic="307"
        maxkick="255"
        maxgecos="128"
        maxaway="200">

####### LOGGING #######

<log method="file" type="* -USERINPUT -USEROUTPUT" level="default" target="logs/ircd.log">

####### WHOWAS OPTIONS #######

<whowas
        groupsize="10"
        maxgroups="100000"
        maxkeep="3d">

####### BAN OPTIONS #######

<badip
       ipmask="192.0.2.69"
       reason="No porn here thanks.">

<badnick
         nick="ChanServ"
         reason="Reserved For Services">

<badnick nick="NickServ" reason="Reserved For Services">
<badnick nick="OperServ" reason="Reserved For Services">
<badnick nick="MemoServ" reason="Reserved For Services">

<badhost
         host="[email protected]">

<badhost host="root@*" reason="Don't IRC as root!">
<badhost host="[email protected]/24" reason="This subnet is bad.">

# exception: Hosts that are exempt from [kgz]lines.
<exception
           host="[email protected]"
           reason="Oper's hostname">

####### INSANE BAN OPTIONS #######

<insane
        hostmasks="no"
        ipmasks="no"
        nickmasks="no"
        trigger="95.5">

Edit the server configuration block for your server:

name: Hostname or FQDN of the server

description: Your server description

id: SID of the server - 2 number with 1 letter

network: name of your network

Edit the admin info.

name: the real name

nick: nick used on IRC network

email: email of admin

Edit the bind address for port and the ssl configuration.

address: server IP address - not a hostname

port: port usage

type: clients or servers type

ssl: encryption used - openssl or gnutls

edit die and restart configuration.

This configuration is used to set the password to restart or shutdown for trusted ircops.

diepass="mypassword"

restartpass="mypassword"

Save the file and exit.

Now create new file opers.conf for the operator configuration.

vi opers.conf

Paste the oper configuration below:

<class
     name="Shutdown"
     commands="DIE RESTART REHASH LOADMODULE UNLOADMODULE RELOADMODULE GLOADMODULE GUNLOADMODULE GRELOADMODULE"
     usermodes="*"
     chanmodes="*">

<class name="SACommands" commands="SAJOIN SAPART SANICK SAQUIT SATOPIC SAKICK SAMODE OJOIN">
<class name="ServerLink" commands="CONNECT SQUIT RCONNECT RSQUIT MKPASSWD ALLTIME SWHOIS JUMPSERVER LOCKSERV UNLOCKSERV" usermodes="*" chanmodes="*" privs="servers/auspex">
<class name="BanControl" commands="KILL GLINE KLINE ZLINE QLINE ELINE TLINE RLINE CHECK NICKLOCK NICKUNLOCK SHUN CLONES CBAN CLOSE" usermodes="*" chanmodes="*">
<class name="OperChat" commands="WALLOPS GLOBOPS" usermodes="*" chanmodes="*" privs="users/mass-message">
<class name="HostCloak" commands="SETHOST SETIDENT SETIDLE CHGNAME CHGHOST CHGIDENT" usermodes="*" chanmodes="*" privs="users/auspex">

<type
    name="NetAdmin"
    classes="SACommands OperChat BanControl HostCloak Shutdown ServerLink"
    vhost="netadmin.inspircd.co"
    modes="+s +cCqQ">

<type name="GlobalOp" classes="SACommands OperChat BanControl HostCloak ServerLink" vhost="ircop.inspircd.co">
<type name="Helper" classes="HostCloak" vhost="helper.inspircd.co">

####### OPERATOR CONFIGURATION #######

<oper
      name="naruse"
      password="mypassword"
      host="[email protected] [email protected] [email protected] *@*"
      type="NetAdmin">

Save the file and exit.

Eedit the oper config as follows:

name: name used on the net

password: password to gain the oper

host: define your host, if you want to all host or IP can gain the oper access, define as "*@*".

type: type of the operator - NetAdmin, Helper, GlobalOp.

Next, copy the samples of motd and rules file from the examples directory.

cp examples/motd.txt.example motd.txt
cp examples/rules.txt.example rules.txt

Then create the inspircd configuration, you have to create a new file links.conf for the services configuration. We will use anope services.

vi links.conf

Paste configuration below:

<link name="services.inspircd.co"
      ipaddr="127.0.0.1"
      port="7000"
      sid="3AX"
      allowmask="127.0.0.0/8"
      sendpass="iamalive"
      recvpass="iamalive">

<uline server="services.inspircd.co" silent="yes">

Save and exit.

Then copy the modules configuration from examples directory.

cp examples/modules.conf.example modules.conf

edit modules.conf and uncomment the modules below:

m_alias - line 65
m_chghost.so - line 463
m_customprefix - line 628
m_globops - line 814
m_hidechans - line 842
m_services_account - line 1630
m_svshold.so - line 1795
m_spanningtree - line 1902

Save and exit.

And finally, go back to the inspircd directory, and then start the inspircd.

cd ~/inspircd/
./inspircd start

Start ircd

If you want to check the inspircd port, you can use the netstat command below:

netstat -plntu

You can see port 6697 and 7000 opened.

Inspircd has been successfully installed.

Step 5 - Install and configure Anope Services

From the irc user, switch to root by typing 'exit' or press ctrl + d, then install cmake. It's needed for anope installation.

exit
yum -y install cmake

Now back to irc user and download anope:

su - irc
wget https://github.com/anope/anope/archive/2.0.3.tar.gz

Extract anope and compile it.

tar -xzvf 2.0.3.tar.gz
cd anope-2.0.3/

Compile and install anope services:

./Config

You will be asked about the directory installation, just press enter.

Build Anope

Go to the build directory and install it:

cd build/
make
make install

This will take some time, don't interrupt the process.

When the anope installation is done, got the home directory, remove anope and go to the services directory.

cd ~/
rm -rf anope-2.0.3/
cd services/

The services configuration is available in the conf directory, so go to that directory and copy example.conf to services.conf.

cd conf/
cp example.conf services.conf

Edit the configuration file with vi:

vi services.conf

line 92 and 93, define your IRC services, it's must match with the inspircd.configuration.

name = "services.inspircd.co"
value = "services.inspircd.co"

line 195, configure the link to the IRC server.

host = "127.0.0.1"
ssl = no
port = 7000
password = "iamalive"

line 198 for server info:

name = "services.inspircd.co"

Now line 263, define the ircd software used:

name = "inspircd20"

line 293, give the network info name:

name = "services.inspircd.co"

Save and exit.

When all this is done, start anope services in bin directory:

cd ~/services/bin/
./anoperc start

If you see the results like on this pic, you have successfully configured the anope services for the inspircd.

Start Anope

Step 5 - Testing

To ensure that everything works as expected, we should now test the IRC server that we've created.

We run IRC on IP 192.168.1.102 and IRC SSL port on 6697.

Open an IRC client like xchat, hexchat or irssi and connect to the server.

In this tutorial, we will use hexchat.

Connect to the server.

/server -ssl 192.168.1.104 6697

Make user as netadmin or operator.

/oper naruse mypassword

Testing anope services.

/msg NickServ HELP

IRC Server is running

InspIRCd and Anope are installed and configured successfully.

Conclusion

InspIRCd is one of the best IRC servers written in C++. It provides high performance and stability, is customizable and there are many ready made modules available. Anope provides flexible IRC services and is easy to use and configure.

Share this page:

3 Comment(s)

Add comment

Comments

From: Jo

I'm getting Error while loading os_oline: Your IRCd does not support OMODE. when trying to start anope?

It connects and then disconnects straight away saying connection reset by host :(

Can you help? :)

From: Long

 I followed everything above but when i start anope i get this?

any hints where to look 

[Aug 30 15:05:24 2016] Loading modules...

[Aug 30 15:05:24 2016] Error while loading os_oline: Your IRCd does not support OMODE.

[Aug 30 15:05:24 2016] Using IRCd protocol inspircd20

[Aug 30 15:05:24 2016] Loading databases...

[Aug 30 15:05:24 2016] DB_FLATFILE: Unable to open data/anope.db for reading!

[Aug 30 15:05:24 2016] Databases loaded

[Aug 30 15:05:24 2016] Attempting to connect to uplink #1 127.0.0.1 (127.0.0.1), port 7000

[Aug 30 15:05:24 2016] Successfully connected to uplink #1 127.0.0.1:7000

[Aug 30 15:05:24 2016] Lost connection from uplink #1 (127.0.0.1:7000): Connection reset by peer

[Aug 30 15:05:24 2016] Unable to connect to any uplink

 

From: Anna Thomas

Your inspircd.conf doesn't include the other conf files, which is why commenter 'Long' is getting uplink error. modules.conf isn't being included and thus m_spanningtree.so isn't loaded and thus services won't connect.

Need to add this plus other confs to inspircd.conf:

<include file="conf/modules.conf">