Rhel6服务器xinetd超级守护进程浅谈

本文发布时间: 2019-Mar-22
1、xinetd为linux下的rhel6超级守护进程,rhel5超级守护进程为inetd安装超级守护进程[root@rootbug~]#yum install xinetd超级守护进程的作用只要是将普通服务进程如:rsync、ftp、tftp等服务进程托管到超级守护进程中进行安全管理2、查看超级守护进程开启情况[root@rootbug ~]# chkconfig --list |grep xinetdxinetd0:off 1:off 2:off 3:on 4:on 5:on 6:off从中可以查看到xinetd是否为开机启动,如果有其他进程托管到超级守护进程下,此命令也可以列出它们的启动情况。如果没有可以设置开机启动[root@rootbug ~]#chkconfig --level 2345 xinetd on3、配置一般服务托管到超级守护进行下(1)以rsync服务为例[root@rootbug ~]#vim/etc/xinetd.d/rsync -------如果xinetd目录下没有rsync,则通过vim新创建service rsync --服务名{disable = yes --disable等于yes表示此服务关闭socket_type =stream --tcp的连线机制wait =no --不等待,可以同时进行大量连线功能user =root --用root身份启动服务server = /usr/bin/rsync --定义你的rsync的服务执行文件的位置server_args =--daemon --服务参数,man rsync可以查到这个参数,表示rsync以守护进程的方式来运行log_on_failure +=USERID --登录错误时,额外记录你的用户id}(2)然后停止之前rsync的服务,启用超级守护进程[root@rootbug ~]#/etc/init.d/rsync stop[root@rootbug ~]#/etc/init.d/xinetd start(3)实现把ssh拖管到super daemon下管理[root@rootbug ~]# vim/etc/xinetd.d/ssh --新建一个文件,写上下面的内容每一个参数前用tab键(制表符)隔开,等号两边也要有空格service ssh{disable = nosocket_type = streamprotocol = tcpwait = nouser = rootserver = /usr/sbin/sshdserver_args = -i}[root@rootbug ~]#/etc/init.d/sshdstop --------关闭之前的服务[root@rootbug ~]#/etc/init.d/xinetdrestart ---------启动超级守护进程[root@rootbug ~]#netstat -ntlup |grep :22tcp 0 00.0.0.0:22 0.0.0.0:* LISTEN 8182/xinetd --这时候查看你的端口会发现守护进程为xinetd,不是以前的sshd(4)如果想让某一IP段可以ssh访问我的服务器,其他都不允许该如何配置?配置如下:[root@rootbug ~]# vim /etc/xinetd.d/sshservice ssh{disable = nosocket_type = streamprotocol = tcpwait = nouser = rootserver = /usr/sbin/sshdserver_args = -ionly_from =10.10.10.0/24 --允许10.10.10.0/24网段访问no_access =10.10.10.104 --拒绝10.1.1.104访问}保存刷新服务[root@rootbug ~]#/etc/init.d/xinetd reload此时当104或者其他网络段的终端ssh访问服务器时会提示如下信息:[root@a ~]# ssh 10.10.10.254ssh_exchange_identification: Connection closed by remote host--被拒绝后报错如上(5)定义监听的端口由22换成2222并且只能上午10点到下午2点之间才能被ssh,服务器总共只允许2个ssh连接,每个源IP只能最多有1个ssh连接,并将日志记录到/var/log/xinetd_ssh.log[root@rootbug ~]#manxinetd.conf --查找access_times 、 log_type、 instances 、per_source 、 port[root@rootbug ~]#vim/etc/services --把ssh对应的22端口改成2222[root@rootbug ~]#vim /etc/xinetd.d/sshservice ssh{disable = nosocket_type = streamprotocol = tcpport = 2222wait = nouser = rootserver = /usr/sbin/sshdserver_args = -ionly_from = 10.10.10.0/24no_access = 10.10.10.35access_times = 10:00-14:00instances = 2per_source = 1log_type = file /var/log/xinetd_ssh.log}刷新服务[root@rootbug ~]#/etc/init.d/xinetdreload --------建议刷新服务,这样不影响其他的超级守护进程服务。如果只有一个守护进程可以直接用restart进行重启。[root@rootbug ~]## netstat -ntlup |grep 2222tcp 0 00.0.0.0:2222 0.0.0.0:* LISTEN 3993/xinetd


(以上内容不代表本站观点。)
---------------------------------
本网站以及域名有仲裁协议。
本網站以及域名有仲裁協議。

2024-Mar-04 02:10pm
栏目列表