I stumbled over the following issue, while debugging ssh connections. I have a Ubuntu 24.04 with openssh-server installed. The corresponding systemd-service is running (now named ssh.service & ssh.socket on 24.04).
I checked for open sockets that listen on port 22. To my surprise there was no socket that listens on IPv4. The only entry is seen for IPv6. Nevertheless, i was able to connect via IPv4 (127.0.0.1 and the given DHCP address). What i expected is the behavior that is found on my older Ubuntu 22.04, where two sockets listen, one for IPv4 & IPv6. I know that there has something changed on the ssh(d) service in the latest Ubuntu, nevertheless, this way to detect open(listen) sockets seems to be "broken".
Questions:
Is this expected behavior?
Why did this change?
How to reliably detect all listening sockets
(for IPv4/6)?
Missing IPv4 listening socket:
Ubuntu 24.04 | openssh-server/noble-updates,now 1:9.6p1-3ubuntu13.5 amd64
$ sudo netstat -peant | grep 22
<HERE I WOULD EXPECT AN ENTRY>
tcp6 0 0 :::22 :::* LISTEN 0 13806 1/init
$ sudo ss -tln | grep 22
<HERE I WOULD EXPECT AN ENTRY>
LISTEN 0 4096 *:22 *:*
$ sudo ss -tln -4 | grep 22
<EMPTY: HERE I WOULD EXPECT AN ENTRY>
Expected:
Ubuntu 22.04.4 LTS | openssh-server/jammy-updates,jammy-security,now 1:8.9p1-3ubuntu0.10 amd64
$ sudo netstat -peatn | grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 27791 1381/sshd: /usr/sbi
tcp6 0 0 :::22 :::* LISTEN 0 27793 1381/sshd: /usr/sbi
$ sudo ss -tln | grep 22
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*