解决telnet: connect to address 127.0.0.1: Connection refused的错误信息(2)

来源:互联网 发布:软件检测员待遇怎么样 编辑:程序博客网 时间:2024/04/29 22:52

检查是否安装成功。

[root@localhost software]# rpm -qa telnet-server
telnet-server-0.17-47.el6_3.1.i686

已经安装好telnet-server服务啦,但由于telnet服务是由xinetd守护的,所以我们需要重新启动xinetd。

[root@localhost software]# service xinetd restart
停止 xinetd:[确定]
正在启动 xinetd:[确定]

启动成功,我们来测试一下连接是否正常。

[root@localhost software]# netstat -tnl | grep 23
tcp        0      0 0.0.0.0:36232               0.0.0.0:*                   LISTEN     
tcp        0      0 :::23                       :::*                        LISTEN     

[root@localhost software]# telnet localhost 23
Trying ::1...
Connected to localhost.
Escape character is '^]'.
CentOS release 6.4 (Final)
Kernel 2.6.32-358.11.1.el6.i686 on an i686
login:

如果无法连接到telnet,哪么需要修改/etc/xinetd.d/telnet文件

[root@localhost software]# vi /etc/xinetd.d/telnet

# default: on
# description: The telnet server serves telnet sessions; it uses \
#       unencrypted username/password pairs for authentication.
service telnet
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/in.telnetd
        log_on_failure  += USERID
        #disable                = yes
}

将disable=yes行前加#注释掉,或者把yes改为no

然后重新启动xinetd服务

[root@localhost software]# service xinetd restart
停止 xinetd:[确定]
正在启动 xinetd:[确定]

或者需要开启防火墙的23端口,我们可以配置一下防火墙,添加telnet的23端口服务

[root@localhost software]# setup

文本模式设置工具 1.19.9                       (c) 1999-2006 Red Hat, Inc
┌─────┤ 选择一种工具 ├─────┐
│                         │
│        防火墙配置        │
│        键盘配置          │
│        网络配置          │
│        系统服务          │
│        验证配置          │
│                          │
│  ┌──────────┐  ┌──────┐  │
│  │ 运行工具 │  │ 退出 │  │
│  └──────────┘  └──────┘  │
│                          │
│                          │
└──────────────────────────┘
    <Tab>/<Alt-Tab> 在元素间切换  |    使用 <Enter>

 我们也可以采用命令行形式添加规则到防火墙中

# vi /etc/sysconfig/iptables

添加一条配置规则,如要想开放23的端口,如下所示:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT

重启iptables

# /etc/init.d/iptables restart

看下状态

# /etc/init.d/iptables status

(1) 重启后永久性生效:

开启:chkconfig iptables on

关闭:chkconfig iptables off

(2) 即时生效,重启后失效(即重启后防火墙自动开启):

开启:service iptables start

关闭:service iptables stop

0 0
原创粉丝点击