yum install -y netcat 安装netcat时提示错误
二、更改/etc/yum.repos.d/CentOS-Base.repo配置文件
三、 下载新的镜像CentOS-Base.repo 到 /etc/yum.repos.d/
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