无法连接到 SSH 服务器:端口 22:没有到主机的路由

无法连接到 SSH 服务器:端口 22:没有到主机的路由

我想将我的笔记本电脑连接到运行 ssh 服务器的路由器,该服务器的192.168.0.1以太网接口上的静态 IP 地址为。我以前可以这样做,但现在出于某种原因,它显示ssh: connect to host 192.168.0.1 port 22: No route to host。以前我可以连接到服务器,我的笔记本电脑获取 IP 地址的方式是Automatic (DHCP),但现在它无法连接Automatic。我将笔记本电脑的 IP 设置为静态192.168.0.66。以下是命令的输出route:(以太网接口是enp3s0f1

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         rtr-35-12-211-1 0.0.0.0         UG    600    0        0 wlp4s0
roswell.egr.msu rtr-35-12-211-1 255.255.255.255 UGH   600    0        0 wlp4s0
35.12.211.0     *               255.255.255.0   U     600    0        0 wlp4s0
link-local      *               255.255.0.0     U     1000   0        0 enp3s0f1
192.168.0.0     *               255.255.255.0   U     100    0        0 enp3s0f1

以下是 的输出ifconfig

enp3s0f1  Link encap:Ethernet  HWaddr X:X:X:X:cb:2b  
          inet addr:192.168.0.66  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::1c11:5c64:f2dd:91b6/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:984 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:142942 (142.9 KB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:3960 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3960 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:379355 (379.3 KB)  TX bytes:379355 (379.3 KB)

wlp4s0    Link encap:Ethernet  HWaddr X:X:X:X:7a:0d  
          inet addr:35.12.211.223  Bcast:35.12.211.255  Mask:255.255.255.0
          inet6 addr: fe80::280b:9f10:ce0d:7d94/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:300950 errors:0 dropped:0 overruns:0 frame:0
          TX packets:58621 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:321081707 (321.0 MB)  TX bytes:10520862 (10.5 MB)

我无法 ping 通服务器。我无法 ssh 我的 IP 地址和环回 (显示port 22: Connection refused)。

编辑:这是我的 ssh 配置文件:

# This is the ssh client system-wide configuration file.  See
# ssh_config(5) for more information.  This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
#  1. command line options
#  2. user-specific file
#  3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options.  For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.

Host *
#   ForwardAgent no
#   ForwardX11 no
#   ForwardX11Trusted yes
#   RhostsRSAAuthentication no
#   RSAAuthentication yes
#   PasswordAuthentication yes
#   HostbasedAuthentication no
#   GSSAPIAuthentication no
#   GSSAPIDelegateCredentials no
#   GSSAPIKeyExchange no
#   GSSAPITrustDNS no
#   BatchMode no
#   CheckHostIP yes
#   AddressFamily any
#   ConnectTimeout 0
#   StrictHostKeyChecking ask
#   IdentityFile ~/.ssh/identity
#   IdentityFile ~/.ssh/id_rsa
#   IdentityFile ~/.ssh/id_dsa
#   IdentityFile ~/.ssh/id_ecdsa
#   IdentityFile ~/.ssh/id_ed25519
#   Port 22
#   Protocol 2
#   Cipher 3des
#   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
#   MACs hmac-md5,hmac-sha1,[email protected],hmac-ripemd160
#   EscapeChar ~
#   Tunnel no
#   TunnelDevice any:any
#   PermitLocalCommand no
#   VisualHostKey no
#   ProxyCommand ssh -q -W %h:%p gateway.example.com
#   RekeyLimit 1G 1h
    SendEnv LANG LC_*
    HashKnownHosts yes
    GSSAPIAuthentication yes
    GSSAPIDelegateCredentials no

答案1

我猜测切换到非自动 DHCP 模式后您的网络设置不正确。

您的路线表显示:

default         rtr-35-12-211-1 0.0.0.0         UG    600    0        0 wlp4s0

这意味着你的默认路由是通过 WiFi 接口设置的。这将使您的以太网数据包被路由到 35.12.211.0/24 网络,从而使您的目标 SSH 服务器无法访问。

相关内容