一.问题描述
我在自己电脑安装了Linux 虚拟机,然后设置了Linux 虚拟机IP,windows上能正常ping 通Linux 虚拟机上IP,采用了FileZilla连接Linux 虚拟机,出现错误: Network error: Connection refused 无法连接到服务器。
二.Linux 虚拟机的排查
1、查看SSH服务有没有安装
#rpm -qa | grep ssh

2、查看SSH服务有没有开启
#/etc/init.d/sshd status

3、查看所有的端口
#netstat -tlnp

4、查看ssh使用的22号端口有没有enable
#netstat -an|grep 22


5、采用SSH能不能正常连接
#ssh root@192.168.1.100

6、把Linux防火墙都关闭

结论:Linux上的SSH是没问题的。
三.Winows的排查
1、ping Linux 虚拟机上IP
>ping 192.168.1.100

2、telnet Linux 虚拟机上IP

3、ipconfig 查看IP的情况

四、问题的解决
我们从ipconfig可以看出,跟自己的电脑IP一样,自己的电脑IP是自动获取的,所以需修改Linux 虚拟机上IP。
第一步:修改
#vi /etc/sysconfig/network-scripts/ifcfg-eth0
#ifconfig eth0

第二步:设置你的VMware(如果connection为NAT就不用再重新设置)
设置你的VMware:在虚拟机上部有个设置选项VM,选择VM->setting->Hardware->Network Adapter,将右边的Network connection选为NAT,点击OK
第三步:在windows查看你的VM8虚拟网卡的IP
例如:Linux虚拟机上IP:192.168.2.200
网络连接VM8虚拟网卡的IP :192.168.2.1
第四步:ipconfig 查看IP是否已经改过来了

第五步:windows telnet 能不能连接


第六步:FileZilla能正常连接Linux 虚拟机,端口默认是22

这个问题排查了很久,没想到IP会设置跟windows一样,希望对有碰到的相同的问题,能作为参考,快速找到问题。