How is it possible to connect via TCP IPv4 into a socket where only TCP IPv6 is listening?

Solution Verified - Updated -

Issue

When listening sockets for some particular port are listed on a rhel-7, only IPv6 sockets are listed on that
particular port.

But still, IPv4 connections are able to establish, how come?

The example below is for a test application acting as a server here, listening on TCP port 3005:

# netstat -nlt6
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp6       0      0 :::22                   :::*                    LISTEN     
tcp6       0      0 ::1:25                  :::*                    LISTEN     
tcp6       0      0 :::3005                 :::*                    LISTEN   
# netstat -nlt4
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN

So as can be seen in the example above there is only IPv6 listening socket on the TCP port 3005.
But IPv4 TCP clients are still able to establish a connection to this port.

# telnet 127.0.0.1 3005
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
# netstat -nt4
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 127.0.0.1:57634         127.0.0.1:3005          ESTABLISHED
# netstat -nt6
Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp6       0      0 127.0.0.1:3005          127.0.0.1:57634         ESTABLISHED

As can be seen in the two established connections list there is a connection over IPv4 from the client-side (port 57612) as well as a connection over IPv6 from the server-side.

WHY?

Environment

Rhel-7

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In