解决yum安装netcat出现Loaded plugins: fastestmirror, refresh-packagekit, http://mirror.centos.org/centos问题

yum install -y netcat  安装netcat时提示错误 

一、确保虚拟机的网络通,能ping通百度即可

二、更改/etc/yum.repos.d/CentOS-Base.repo配置文件

三、 下载新的镜像CentOS-Base.repo 到 /etc/yum.repos.d/ 

 四. 安装netcat

五、测试


yum install -y netcat  安装netcat时提示错误 

[root@LLZ ~]# yum install -y nc
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
http://mirror.centos.org/centos/6/extras/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: extras. Please verify its path and try again
[root@LLZ ~]# yum install -y nc
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
http://mirror.centos.org/centos/6/extras/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: extras. Please verify its path and try again

看了很多博客,说是防火墙没关,DNS配置不正确之类的,跟着 改了一大堆,都没有用。仔细看提示,说的是http://mirror.centos.org/centos/6/extras/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"这个地址找不到,这个地址是国外的地址,现在好像停止了访问。具体解决方法如下:

注:本次操作要在root用户下才能执行,不然会报错

一、确保虚拟机的网络通,能ping通百度即可

如果不能ping通百度,按下表面步骤操作即可

1. vi /etc/sysconfig/network-scripts/ifcfg-eth0 
#在其中添加如下信息

2. DNS1=8.8.8.8

3. service network restart   #刷新网卡信息

然后 

4. vi /etc/resolv.conf

#在其中添加如下信息

5. nameserver 8.8.8.8

#注意这里的8.8.8.8要与ifcfg-eth0 中的DNS1对应一致

然后

6. ping www.baidu.com   就能ping通丽

二、更改/etc/yum.repos.d/CentOS-Base.repo配置文件

1. yum clean all     #清除yum缓存

2.  vi  /etc/yum.repos.d/CentOS-Base.repo   #把文件中的内容全部删除之后,将下面代码添加到文件

[base]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
 
[updates]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
 
[extras]
name=CentOS-$releasever
enabled=1
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
 
[centosplus]
name=CentOS-6.10 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6
 
[contrib]
name=CentOS-6.10 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos-vault/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos-vault/centos/RPM-GPG-KEY-CentOS-6

#注意把上面的代码复制的时候不要复制错哦,因为我每次都是全选直接复制上去的,但是每次代码的第一句[base]总是会给我复制少了,以防后面执行报错,又回来修改,这里复制的时候要注意复完全哦
3. reboot #重新启动虚拟机

三、 下载新的镜像CentOS-Base.repo 到 /etc/yum.repos.d/ 

(我的是Centos6.5,我使用的是1. CentOS6镜像下载中的第一个然后成功的)

1. CentOS6镜像下载

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo

或者

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo

2. Centos7镜像下载 

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

3. Centos8镜像下载 

wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

或者

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo

 四. 安装netcat

yum install -y nc   #nc是netcat的缩写

或者

yum install -y netcat

出现Complete! 就算安装成功啦

五、测试

1. [root@LLZ ~]# nc -help
usage: nc [-46DdhklnrStUuvzC] [-i interval] [-p source_port]
          [-s source_ip_address] [-T ToS] [-w timeout] [-X proxy_version]
          [-x proxy_address[:port]] [hostname] [port[s]]
        Command Summary:
                -4              Use IPv4
                -6              Use IPv6
                -D              Enable the debug socket option
                -d              Detach from stdin
                -h              This help text
                -i secs         Delay interval for lines sent, ports scanned
                -k              Keep inbound sockets open for multiple connects
                -l              Listen mode, for inbound connects
                -n              Suppress name/port resolutions
                -p port         Specify local port for remote connects
                -r              Randomize remote ports
                -S              Enable the TCP MD5 signature option
                -s addr         Local source address
                -T ToS          Set IP Type of Service
                -C              Send CRLF as line-ending
                -t              Answer TELNET negotiation
                -U              Use UNIX domain socket
                -u              UDP mode
                -v              Verbose
                -w secs         Timeout for connects and final net reads
                -X proto        Proxy protocol: "4", "5" (SOCKS) or "connect"
                -x addr[:port]  Specify proxy address and port
                -z              Zero-I/O mode [used for scanning]
        Port numbers can be individual or ranges: lo-hi [inclusive]
[root@LLZ ~]# 
 

2. [root@LLZ ~]# nc -l 4444
hello,world
spark,hadoop

  • 6
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小-枝-丫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值