I'm trying to connect to my Pi over ssh while connected directly with ethernet - but I can't.
I have my Pi, which I connect to the PC over ethernet directly. Problem is - the PC stopped seeing the Pi. Here are some tests that I run:
ifconfig on the PC:
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.42.0.1 netmask 255.255.255.0 broadcast 10.42.0.255
inet6 fe80::36db:997a:ac32:11a8 prefixlen 64 scopeid 0x20<link>
ether 00:2b:67:64:60:41 txqueuelen 1000 (Ethernet)
RX packets 4 bytes 814 (814.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 31 bytes 4790 (4.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
nmap scan on the PC:
Starting Nmap 7.80 ( https://nmap.org ) at 2023-06-16 08:50 CEST
Nmap scan report for ThinkPad (10.42.0.1)
Host is up.
Nmap done: 256 IP addresses (1 host up) scanned in 10.54 seconds
ifconfig on the Pi:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.71.238 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::c15b:7164:30b1:d79 prefixlen 64 scopeid 0x20<link>
ether d8:3a:dd:0f:72:9d txqueuelen 1000 (Ethernet)
RX packets 7 bytes 1228 (1.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 47 bytes 7021 (6.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
I've also tried manually setting the IP address on the Pi, but to no avail:
ifconfig on the Pi:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.42.0.116 netmask 255.255.255.0 broadcast 10.42.0.255
inet6 fe80::f283:6fd7:3316:cf3f prefixlen 64 scopeid 0x20<link>
ether d8:3a:dd:0f:72:9d txqueuelen 1000 (Ethernet)
RX packets 4602 bytes 655025 (639.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 3675 bytes 744521 (727.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
but the nmap scan on the PC shows nothing:
$ nmap -sn 10.42.0.255/24
Starting Nmap 7.80 ( https://nmap.org ) at 2023-07-12 10:12 CEST
Nmap scan report for ThinkPad (10.42.0.1)
Host is up (0.00057s latency).
Nmap done: 256 IP addresses (1 host up) scanned in 3.10 seconds
and the same goes for the nmap scan on the Pi:
$ nmap -sn 10.42.0.255/24
Starting Nmap 7.80 ( https://nmap.org ) at 2023-07-12 10:15 CEST
Nmap done: 256 IP addresses (0 hosts up) scanned in 0.03 seconds
I can connect to the Pi when I connect it via a router, and another PC can just simply connect to the Pi via ethernet directly (the difference between the PCs is the OS - I'm using Ubuntu 22.04, the other PC is using 20.04). Pi is running bullseye.
Any help would be appreciated, as I don't really know what to do next. I think it's a PC problem (a config related one), but I have no idea what I could do. I've already set the the IPv4 and IPv6 method to be 'shared to other computers' on the PC.
Edit:
As per suggestions, I've once again manually set the IP address on the Pi ifconfig eth0 10.42.0.116 netmask 255.255.255.0
and run ifconfig eth0 up
. The nmap
scan on the PC still didn't see the Pi. I've also run netstat -rn
on the PC:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlp4s0
10.42.0.0 0.0.0.0 255.255.255.0 U 0 0 0 enp2s0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 wlp4s0
And I've run netstat -rn
on the Pi:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 wlan0
169.254.0.0 0.0.0.0 255.255.0.0 U 0 0 0 eth0
So it seems like the IP address I'm trying to set didn't actually set? And there is another network on 169.254.0.0 netmask 255.255.0.0
that the ifconfig
on the PC didn't show me? Btw here both the PC and the Pi are connected to the same WiFi, but this is just for troubleshooting and will not be available 'in the field'.
Edit again: Complete output of ip addr
from the Pi with the self-assigned address:
$ ip addr
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 e4:5f:01:a6:68:ff brd ff:ff:ff:ff:ff:ff
inet 169.254.240.210/16 brd 169.254.255.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::7102:dc3:1a73:1aab/64 scope link
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether e4:5f:01:a6:69:00 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.196/24 brd 192.168.1.255 scope global dynamic noprefixroute wlan0
valid_lft 7135sec preferred_lft 6235sec
inet6 fe80::1796:1cb:7078:19cd/64 scope link
valid_lft forever preferred_lft forever
ssh
is enabled. As you can CLEARLY SEE IN THE POST - it gets some random IP address that's not in the PC's range: the Pi's IP over ethernet:169.254.71.238
while the PC's IP and netmask are:10.42.0.1 netmask 255.255.255.0
. And the error I get when I try tossh
using this random IP isno route to host
. How I'm trying to connect isssh pi@IP-address
which would bessh [email protected]
.ssh [email protected]