How is it possible to connect via TCP IPv4 into a socket where only TCP IPv6 is listening?
Issue
When listening sockets for some particular port are listed on RHEL, only IPv6 sockets are listed on that
particular port.
Why are IPv4 connections are still being establied?
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) and a connection over IPv6 from the server-side.
Environment
Red Hat Enterprise Linux (RHEL)
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.