Home > Operation and Maintenance > CentOS > What to do if xshell fails to connect to centos

What to do if xshell fails to connect to centos

藏色散人
Release: 2022-01-28 11:37:29
Original
10020 people have browsed it

xshell连接centos失败的解决办法:1、打开虚拟机,设置子网IP;2、设置网关IP;3、修改网卡文件内容;4、通过“systemctl restart network”重启网络即可。

What to do if xshell fails to connect to centos

本文操作环境:CentOS 7系统、DELL G3电脑

xshell连接centos失败怎么办?

Xshell连接CentOS失败,记录一次CentOS7.6网络连接的步骤(笔记)

问题:本来在公司可以正常连接网络,回到学校换了学校的无线网络之后连接不上网络,Xshell连接Linux失败,CentOSping外网不通,这里记录一下解决办法(通过设置Linux静态Ip)。

  1. 打开虚拟机-编辑-虚拟网络编辑器-设置子网IP
    What to do if xshell fails to connect to centos

  2. 上图打开NAT设置之后,设置网关IP(要和子网IP在一个网段)
    What to do if xshell fails to connect to centos

  3. 修改网卡文件内容,使用vim模式打开网卡文件

    打开网卡文件命令:
    vi /etc/sysconfig/network-scripts/ifcfg-ens33
    如果不知道网卡文件名,可以使用以下命令查看:
    ll /etc/sysconfig/network-scripts/ | grep ifcfg-en
    打开之后修改和添加如下:
    What to do if xshell fails to connect to centos

BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.25.73
GATEWAY=192.168.25.2
NETMASK=255.255.255.0
DNS1=114.114.114.114
DNS2=8.8.8.8
Copy after login
  • IPADDR:为设置的IP,更改为和子网IP在同一网段的自定义IP
  • GATEWAY:为虚拟网络编辑器设置的网关IP,这个要与自己的网关IP一致(注意)
  • NETMASK:子网掩码
  • 其它都一致即可

查看网关IP:
What to do if xshell fails to connect to centos

  1. 设置完成之后,保存退出,重启网络systemctl restart network
  2. 查看CentOS中的IP,通过ip addr命令查看
    What to do if xshell fails to connect to centos
  3. 打开WIndows下的命令行,输入cmd进入命令行,然后输入ipconfig命令查看IP,确保和CentOS下的IP在同一个网段即为设置成功
    What to do if xshell fails to connect to centos
  4. 设置成功之后,本机pingCentOS,CentOSping本机,CentOSping外网都可以成功!!!

推荐:《centos使用教程

The above is the detailed content of What to do if xshell fails to connect to centos. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template