CentOS环境下配置安装IRC聊天
前言
最近比较忙碌,都没什么时间写博客,遥想前几个月,大D与友人小聚,说起IRC这个古老的聊天室聊天方式,使大D萌生了搭建一个IRC聊天服务器的想法,断断续续搞了几天,基本算是搞定了,遂成此文。
IRC是什么
IRC(Internet Relay Chat的缩写,“因特网中继聊天”)是一种通过网络的即时聊天方式。其主要用于群体聊天,但同样也可以用于个人对个人的聊天。
IRC是一种公开的协议,采用TCP和SSL协议。一个IRC服务器可以连接其他的IRC服务器以扩展为一个IRC网络。IRC用户通过客户端软件和服务器相连。大多数的IRC服务器不需要客户注册登录,虽然在连接前必须设定好昵称(nickname),但客户端一般都会自动分给一个。
搭建背景
这里大D决定使用虚拟机来进行搭建,说明如下
OS:CentOS 6.7
RAM:1 G
HDD:20 G
CPU:1 Core
Network: NAT DHCP关闭 分配IP:192.168.10.109
正文
IRC服务的Linux程序多种多样,这里大D选择使用口碑较好的UnrealIRCd。
首先我们要安装编译UnreallRCd时需要的一些依赖程序。
安装openssl,openssl-devel,gcc,gcc-dev
1 |
[root@localhost ~]# yum install openssl openssl-devel gcc gcc-dev -y |
为了安全性考虑,新建一个账户用于运行UnreallRCd
新建账户
1 2 3 |
[root@localhost ~]# useradd ircs [root@localhost ~]# passwd ircs |
新建账户并设置密码后使用该账户登录系统,接下来的操作均在新建的这个用户上进行。
下载源码
1 |
[ircs@localhost ~]$ wget --no-check-certificate --trust-server-names https://www.unrealircd.org/downloads/unrealircd-latest.tar.gz |
需要注意的问题是,如果是国内主机的话,可能会无法连接到www.unrealircd.org,更换DNS然后多下载几次就好了。
解压源码并编译安装
1 2 3 4 |
tar -zxvf unrealircd-4.0.3.1.tar.gz cd unrealircd-4.0.3.1.tar.gz ./Config |
执行./Config
之后,首先显示欢迎界面,并询问是不是在这台机器上第一次安装,如图:
按回车键继续之后会显示用户协议,一路空格+回车即可。
随后会询问一些配置参数,如果没有特殊要求,保持默认,如图:
随后开始进行配置工作,第一阶段配置完成之后会询问是否需要使用openssl进行加密,这里我们选择yes。
然后安装程序会开始配置SSL证书,你需要填写一些信息,如下:
1 2 3 4 5 6 7 |
Country Name (2 letter code) [XX]: #国家 State or Province Name (full name) []: #省份 Locality Name (eg, city) [Default City]: #城市 Organization Name (eg, company) [Default Company Ltd]: #单位名称 Organizational Unit Name (eg, section) []: #部门 Common Name (eg, your name or your server's hostname) []:192.168.159.136 #域名/主机名/IP地址 Email Address []: #邮件地址 |
根据你的情况进行填写就可以了。
配置完成之后,会出现如下画面:
随后执行安装:
1 2 |
[ircs@localhost unrealircd-4.0.3.1]$ make && make install |
安装完成后有如下界面:
修改配置文件
默认安装完毕之后是没有配置文件的,所以我们需要参照示例文件编写我们自己的配置文件,这里将示例配置文件贴出,需要修改的地方大D将作出备注,可以根据实际情况进行修改。
配置文件的位置及文件名为:
1 |
/home/ircs/unrealircd/conf/unrealircd.conf |
根据实际安装情况修改即可。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
include "modules.default.conf"; include "help/help.conf"; include "badwords.conf"; include "spamfilter.conf"; include "operclass.default.conf"; /* me{} 定义了服务器名称、信息、以及服务器ID * 服务器ID(sid)必须以一个数字开始,在IRC网络中需要该ID唯一。 * 该块需要修改 */ me { name "irc.foonet.com"; info "FooNet Server"; sid "001"; }; /* admin{}定义了管理员信息 * 此块需要修改 */ admin { "Bob Smith"; "bob"; "widely@used.name"; }; /* Clients and servers are put in class { } blocks, we define them here. * Class blocks consist of the following items: * - pingfreq: how often to ping a user / server (in seconds) * - connfreq: how often we try to connect to this server (in seconds) * - sendq: the maximum queue size for a connection * - recvq: maximum receive queue from a connection (flood control) */ /* Client class with good defaults */ class clients { pingfreq 90; maxclients 1000; sendq 200k; recvq 8000; }; /* Special class for IRCOps with higher limits */ class opers { pingfreq 90; maxclients 50; sendq 1M; recvq 8000; }; /* Server class with good defaults */ class servers { pingfreq 60; connfreq 15; /* try to connect every 15 seconds */ maxclients 10; /* max servers */ sendq 5M; }; /* Allow blocks define which clients may connect to this server. * This allows you to add a server password or restrict the server to * specific IP's only. You also configure the maximum connections * allowed per IP here. * See also: https://www.unrealircd.org/docs/Allow_block */ /* Allow everyone in, but only 3 connections per IP */ allow { ip *@*; class clients; maxperip 3; }; /* Example of a special allow block on a specific IP: * Requires users on that IP to connect with a password. If the password * is correct then it permits 20 connections on that IP. */ allow { ip *@192.0.2.1; class clients; password "somesecretpasswd"; maxperip 20; }; /* 这里设置了op权限人的名称、密码等信息,需要全部更改。 */ oper bobsmith { class opers; mask *@*; password "test"; /* Oper permissions are defined in an 'operclass' block. * See https://www.unrealircd.org/docs/Operclass_block * UnrealIRCd ships with a number of default blocks, see * the article for a full list. We choose 'netadmin' here. */ operclass netadmin; swhois "is a Network Administrator"; vhost netadmin.mynet.org; }; /* Listen blocks define the ports where the server should listen on. * In other words: the ports that clients and servers may use to * connect to this server. * * Syntax: * listen { * { * ip <ip>; * port <port>; * options { * <options....>; * }; * }; */ /* 标准端口信息 */ listen { ip *; port 6667; }; /* 加密端口信息 */ listen { ip *; port 6697; options { ssl; }; }; /* Special SSL/TLS servers-only port for linking */ listen { ip *; port 6900; options { ssl; serversonly; }; }; /* NOTE: If you are on an IRCd shell with multiple IP's and you use * the above listen { } blocks then you will likely get an * 'Address already in use' error and the ircd won't start. * This means you MUST bind to a specific IP instead of '*' like: * listen { ip 1.2.3.4; port 6667; }; * Of course, replace the IP with the IP that was assigned to you. */ /* * Link blocks allow you to link multiple servers together to form a network. * See https://www.unrealircd.org/docs/Tutorial:_Linking_servers */ link hub.mynet.org { incoming { mask *@something; }; outgoing { bind-ip *; /* or explicitly an IP */ hostname hub.mynet.org; port 6900; options { ssl; }; }; password "00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF"; /* SSL fingerprint of other server */ class servers; }; /* U-lines give other servers (even) more power/commands. * If you use services you must add them here. * NEVER put the name of a (normal) UnrealIRCd server here!!! * ( If you wonder what Services are then see * https://www.unrealircd.org/docs/Services ) */ ulines { services.mynet.org; }; /* Here you can add a password for the IRCOp-only /DIE and /RESTART commands. * This is mainly meant to provide a little protection against accidental * restarts and server kills. */ drpass { restart "restart"; die "die"; }; /* The log block defines what should be logged and to what file. * See also https://www.unrealircd.org/docs/Log_block */ /* This is a good default, it logs almost everything */ log "ircd.log" { flags { oper; connects; server-connects; kills; errors; sadmin-commands; chg-commands; oper-override; tkl; spamfilter; }; }; /* With "aliases" you can create an alias like /SOMETHING to send a message to * some user or bot. They are usually used for services. * * We have a number of pre-set alias files, check out the alias/ directory. * As an example, here we include all aliases used for anope services. */ include "aliases/anope.conf"; /* Ban nick names so they cannot be used by regular users */ ban nick { mask "*C*h*a*n*S*e*r*v*"; reason "Reserved for Services"; }; /* Ban ip. * Note that you normally use /KLINE, /GLINE and /ZLINE for this. */ ban ip { mask 195.86.232.81; reason "Hate you"; }; /* Ban server - if we see this server linked to someone then we delink */ ban server { mask eris.berkeley.edu; reason "Get out of here."; }; /* Ban user - just as an example, you normally use /KLINE or /GLINE for this */ ban user { mask *tirc@*.saturn.bbn.com; reason "Idiot"; }; /* Ban realname allows you to ban clients based on their 'real name' * or 'gecos' field. */ ban realname { mask "Swat Team"; reason "mIRKFORCE"; }; ban realname { mask "sub7server"; reason "sub7"; }; /* Ban and TKL exceptions. Allows you to exempt users / machines from * KLINE, GLINE, etc. * If you are an IRCOp with a static IP (and no untrusted persons on that IP) * then we suggest you add yourself here. That way you can always get in * even if you accidentally place a *LINE ban on yourself. */ /* except ban protects you from KLINE and ZLINE */ except ban { mask *@192.0.2.1; // you may add more mask entries here.. }; /* except tkl with type 'all' protects you from GLINE, GZLINE, QLINE, SHUN */ except tkl { mask *@192.0.2.1; type all; }; /* With deny dcc blocks you can ban filenames for DCC */ deny dcc { filename "*sub7*"; reason "Possible Sub7 Virus"; }; /* deny channel allows you to ban a channel (mask) entirely */ deny channel { channel "*warez*"; reason "Warez is illegal"; class "clients"; }; /* VHosts (Virtual Hosts) allow users to acquire a different host. * See https://www.unrealircd.org/docs/Vhost_block */ /* Example vhost which you can use. On IRC type: /VHOST test test * NOTE: only people with an 'unrealircd.com' host may use it so * be sure to change the vhost::mask before you test. */ vhost { vhost i.hate.microsefrs.com; mask *@unrealircd.com; login "test"; password "test"; }; /* You can include other configuration files */ /* include "klines.conf"; */ /* 网络配置信息 需要修改 尤其是cloak-keys块内的三个钥匙要保证不一样*/ set { network-name "MYNet"; default-server "irc.mynet.org"; services-server "services.mynet.org"; stats-server "stats.mynet.org"; help-channel "#Help"; hiddenhost-prefix "Clk"; prefix-quit "Quit"; /* Cloak keys should be the same at all servers on the network. * They are used for generating masked hosts and should be kept secret. * The keys should be 3 random strings of 50-100 characters * and must consist of lowcase (a-z), upcase (A-Z) and digits (0-9). * HINT: On *NIX, you can run './unrealircd gencloak' in your shell to let * UnrealIRCd generate 3 random strings for you. */ cloak-keys { "aoAr1HnR6gl3sJ7hVz4Zb7x4YwpW"; "and another one"; "and another one"; }; }; /* 服务器信息 这部分信息会显示在登录到IRC服务器之后,以及一些权限的设置 根据实际情况修改即可*/ set { kline-address "set.this.to.email.address"; /* e-mail or URL shown when a user is banned */ modes-on-connect "+ixw"; /* when users connect, they will get these user modes */ modes-on-oper "+xwgs"; /* when someone becomes IRCOp they'll get these modes */ oper-auto-join "#opers"; /* IRCOps are auto-joined to this channel */ options { hide-ulines; /* hide U-lines in /MAP and /LINKS */ show-connect-info; /* show "looking up your hostname" messages on connect */ }; maxchannelsperuser 10; /* maximum number of channels a user may /JOIN */ /* The minimum time a user must be connected before being allowed to * use a QUIT message. This will hopefully help stop spam. */ anti-spam-quit-message-time 10s; /* Or simply set a static quit, meaning any /QUIT reason is ignored */ /* static-quit "Client quit"; */ /* static-part does the same for /PART */ /* static-part yes; */ /* Which /STATS to restrict to opers only. We suggest to leave it to * (ALL) */ oper-only-stats "*"; /* Anti flood protection */ anti-flood { nick-flood 3:60; /* 3 nick changes per 60 seconds (the default) */ connect-flood 3:60; /* 3 connection attempts per 60 seconds (the default) */ away-flood 4:120; /* 4 times per 2 minutes you may use /AWAY (default) */ }; /* Settings for spam filter */ spamfilter { ban-time 1d; /* default duration of a *LINE ban set by spamfilter */ ban-reason "Spam/Advertising"; /* default reason */ virus-help-channel "#help"; /* channel to use for 'viruschan' action */ /* except "#help"; channel to exempt from Spamfilter */ }; }; /* Finally, you may wish to have a MOTD (Message of the Day), this can be * done by creating an 'ircd.motd' text file in your conf/ directory. * This file will be shown to your users on connect. * For more information see https://www.unrealircd.org/docs/MOTD_and_Rules */ /* * Problems or need more help? * 1) https://www.unrealircd.org/docs/UnrealIRCd_4_documentation * 2) https://www.unrealircd.org/docs/FAQ <- answers 80% of your questions! * 3) If you are still having problems then you can get support: * - Forums: https://forums.unrealircd.org/ * - IRC: irc.unrealircd.org / #unreal-support * Note that we require you to read the documentation and FAQ first! */ |
创建完配置文件之后,就可以切换到安装目录启动IRC了。
1 |
[ircs@localhost unrealircd]$ ./unrealircd start |
最后当然就是使用客户端连接了,Windows上推荐使用HexChat这一款客户端,Linux上可以选择使用irssi等IRC聊天客户端。
以上。
已有 4 条评论
发表评论
电子邮件地址不会被公开。 必填项已标注。
沙发!
@adamfei 你博客新模板很不错啊
Pingback: 从放弃Windows到使用IRC – Shank & Tech
我觉得weechat更好用