以太网连接 SSH 超时

以太网连接 SSH 超时

您好,我正在尝试通过连接到主机 PC(Windows 10)的以太网电缆将我的 DE10 纳米板(运行 Debian)连接到互联网。我按照一个简短的教程操作,了解如何在运行 Debian 的树莓派上执行此操作,因为它们非常相似,但我遇到了一些问题。以下是教程的链接: https://www.circuitbasics.com/how-to-connect-to-a-raspberry-pi-directly-with-an-ethernet-cable/

我的问题是我无法使用以太网从我的主机 PC 到我的 de10 开发板创建 SSH 连接,当我尝试使用 ip 地址连接时,SSH 连接将超时。

有人能帮我解决这个问题吗?我在下面提供了一些我认为可能有用的信息。

ip a我的 de10 主板上的输出:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 06:c0:3f:00:d8:5f brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.100/24 brd 192.168.0.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::4c0:3fff:fe00:d85f/64 scope link
       valid_lft forever preferred_lft forever
3: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0

从我的主机来看以太网适配器的信息是:

Ethernet adapter Ethernet 3:
Connection-specific DNS Suffix  . :
Link-local IPv6 Address . . . . . : fe80::ea97:cab3:5d6d:fd4a%24
Autoconfiguration IPv4 Address. . : 169.254.25.112
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :         
         
              

/etc/resolv.conf 的内容:

# Generated by NetworkManager
search localdomain linuxvmimages.local
nameserver 192.168.88.2

命令route -ne返回:

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.0.1     0.0.0.0         UG        0 0          0 eth0
192.168.0.0     0.0.0.0         255.255.255.0   U         0 0          0 eth0

/etc/network/interfaces.d 的内容:

# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo eth0
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet dhcp

iface eth0 inet static  
address 192.168.0.100  
gateway 192.168.0.1  
netmask 255.255.255.0  
network 192.168.0.0  
broadcast 192.168.0.255
dns-nameservers 192.168.88.2

/etc/dhcp/dhclient.conf 的内容:

# Configuration file for /sbin/dhclient.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#   man page for more information about the syntax of this file
#   and a more comprehensive list of the parameters understood by
#   dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#   not leave anything out (like the domain name, for example), then
#   few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;

#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#reboot 10;
#select-timeout 5;
#initial-interval 2;
#script "/sbin/dhclient-script";
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}

#interface eth0
#static ip_address=169.254.25.99
#static routers=192.168.0.1
#static domain_name_servers=192.168.88.2


interface "eth0";
fixed-address 169.254.25.99;
option routers 192.168.0.1;
option domain-name-servers 192.168.88.2;

答案1

您需要将两台设备配置为具有来自同一网络的 IP 地址。由于您目前已使用 配置了 DE10nano 192.168.0.100/24,因此您还需要将 PC 配置为具有来自同一网络的地址(例如192.168.0.7/24将这样做)。

网络前缀(或子网掩码)告诉两台主机哪些地址是连接的本地地址。只要 PC 具有自动配置的169.254.x.x/16地址,它不知道DE10 的 192.168.0.100 可通过该接口使用,而且 DE10 也不知道如何响应 PC。

答案2

因此,您的主板的 IP 是 192.168.0.100。

主机 PC 的 IP 为 169.254.25.112。它位于子网 /16 中。开发板的 IP 不在您的主机的子网中。因此,它们无法通信。

如果你给你的主机一个和你的主板在同一个子网中的 IP,比如说 192.168.0.112 和一个 /24,那么你就应该能够连接。

相关内容