解决Centos6.0下出现protocol not available错误

in 互联网技术 with 0 comment  访问: 6,255 次

报错情况

之前在Centos6.{6 ~ 9}上面使用nc-1.84-24版本模拟端口监听都没有问题,这回在Centos6.0上使用报如下错误:

[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 6.0 (Final)
[root@localhost ~]# rpm -qf /usr/bin/nc
nc-1.84-24.el6.x86_64
[root@localhost ~]# nc -l 9999
nc: Protocol not available

遇到这种情况表示不理解,没有遇到过这种情况,只能借助强大的Google搜索了,搜索到的结果为: https://serverfault.com/questions/729746/netcat-fails-to-start-in-listening-mode, 这里记录一下解决过程。

解决过程

通过搜索引擎可知,这是nc-1.84-24.el6版本的一个Bug, 具体的解决方法就是卸载此版本,然后下载低版本安装适配解决,具体操作步骤如下:

1、删除老版本包

yum erase nc -y

2、手动下载一个官方较低版本包

# x86_64 (64-bit)
wget http://vault.centos.org/6.6/os/x86_64/Packages/nc-1.84-22.el6.x86_64.rpm

# i386 (32-bit)
wget wget http://vault.centos.org/6.6/os/i386/Packages/nc-1.84-22.el6.i686.rpm

3、安装下载的包

rpm -iUv nc-1.84-22.el6.x86_64.rpm

4、验证

[root@localhost src]# rpm -qf /usr/bin/nc
nc-1.84-22.el6.x86_64
[root@localhost src]# nohup nc -l 9999 >/dev/null  2>&1 &
[1] 8498
[root@localhost src]# nc -v -z localhost 9999
Connection to localhost 9999 port [tcp/distinct] succeeded!
[1]+  Done                    nohup nc -l 9999 > /dev/null 2>&1

如上验证结果所示,已经完美适配,我也在Centos6.{4 ~ 9} 版本做了验证,均可以使用,不会再出现nc: Protocol not available的错误。

WeZan