虚拟机的问题:
- 可以ping通主机外网,但是无法连通xshell
- 虚拟机无法安装软件:---gcc编译不能。
- sshpass无sshkey登录主机传输文件
- 可以ping通局域网无法ping通外网百度
一、可以ping通主机外网,但是无法连通xshell
原因:(1)防火墙关闭【不是】
(2)telnet端口【不正常】--没有开启SSH
安装telnet:
yum install xinetd telnet telnet-server –y
测试:
telnet baidu.com 80
测试需要的ip与端口:
telnet 10.96.2.109 22
结果如下:
Trying 10.96.2.109...
telnet: connect to address 10.96.2.109:Connection refused
查看ssh状态:
service sshd status
openssh-daemon 已停
然后卸载重新安装就好,按照下面的这个步骤来
https://blog.csdn.net/lukabruce/article/details/80253138
这个是连通时候的样子,下面的那个代表ctrl+]可以进入telnet命令行。
imagesshd状态检查与重新启动
image二、虚拟机无法安装软件:---gcc编译不能。
Error Downloading Packages:
mpfr-2.4.1-6.el6.x86_64: failure:Packages/mpfr-2.4.1-6.el6.x86_64.rpm from base: [Errno 256] No more mirrors totry.
libgomp-4.4.7-17.el6.x86_64:failure: Packages/libgomp-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] Nomore mirrors to try.
gcc-c++-4.4.7-17.el6.x86_64:failure: Packages/gcc-c++-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] Nomore mirrors to try.
libgcc-4.4.7-17.el6.x86_64: failure:Packages/libgcc-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrorsto try.
cpp-4.4.7-17.el6.x86_64: failure:Packages/cpp-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors totry.
libstdc++-4.4.7-17.el6.x86_64:failure: Packages/libstdc++-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] Nomore mirrors to try.
gcc-4.4.7-17.el6.x86_64: failure:Packages/gcc-4.4.7-17.el6.x86_64.rpm from base: [Errno 256] No more mirrors totry.
cloog-ppl-0.15.7-1.2.el6.x86_64:failure: Packages/cloog-ppl-0.15.7-1.2.el6.x86_64.rpm from base: [Errno 256] Nomore mirrors to try.
ppl-0.10.2-11.el6.x86_64: failure:Packages/ppl-0.10.2-11.el6.x86_64.rpm from base: [Errno 256] No more mirrors totry.
libstdc++-devel-4.4.7-17.el6.x86_64:failure: Packages/libstdc++-devel-4.4.7-17.el6.x86_64.rpm from base: [Errno256] No more mirrors to try.
看报错的大意就是说,镜像找不到,即源没有找到;然后我就到网上搜了下,看可以用下面方法解决:
[Errno 256] No more mirrors to try. 得知这可能是错误的缓存源导致,直接两个命令解决:
yum clean all
yum makecache
但是我这里执行到 yum makecache 这个指令的时候还是又报错如下:
Could not retrieve mirrorlisthttp://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 6 - "Couldn't resolvehost 'mirrorlist.centos.org'"
Error: Cannot retrieve repository metadata(repomd.xml) for repository: base. Please verify its path and try again
[root@app softback]# yum -y install gccgcc-c++
Could not retrieve mirrorlisthttp://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 6 - "Couldn't resolvehost 'mirrorlist.centos.org'"
Error: Cannot retrieve repository metadata(repomd.xml) for repository: base. Please verify its path and try again
[root@app softback]# yum install gcc-c++libstdc++-devel
Could not retrieve mirrorlisthttp://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was
14: PYCURL ERROR 6 - "Couldn't resolvehost 'mirrorlist.centos.org'"
Error: Cannot retrieve repository metadata(repomd.xml) for repository: base. Please verify its path and try again
国内服务器在运行命令yum -y install wget的时候会出现这种问题,
这种错误,是因为没有配置/etc/resolv.conf。
解决方法:编辑resolv.conf文件,添加:
nameserver 8.8.8.8
ps:
resolv.conf这里设置的话,重启可能会失效,建议在网卡那里配置。如下图
image然后重启网络服务即可
三、sshpass无sshkey登录主机传输文件
sshpass -p 密码scp -oStrictHostKeyChecking=no /home/file.txt[root@ip:/home](mailto:root@10.96.2.154:/home)
四、可以ping通局域网无法ping通外网百度。
首先检查一下网络
1.ping127.0.0.1 环回地址,证明本地的TCP/IP没有问题
2.ping本机IP地址,证明本机IP配置没有问题
3.ping本地路由网关10.96.2.1,证明到路由的部分网络没有问题
4.ping公网IP8.8.8.8,证明连接外网没有问题
5.ping www.baidu.com,证明DNS是否问题
IP,DNS配置在配置文件中,路径为vi /etc/sysconfig/network-scripts/ifcfg-eth0 ,设置IP地址和DNS
如果不好用,在进入配置文件vi /etc/resolv.conf,对DNS进行设置
注意这个,/etc/resolv.conf 这里设置了之后可能会没有用。重启失效。最好再/ifcfg-eth0这里面设置
网友评论