If I am listening on :::80, is it listening on all ipv6 or all ipv6+ipv4?
This is my netstat -tln:
tcp 0 0 :::8080 :::*
If I am listening on :::80, is it listening on all ipv6 or all ipv6+ipv4?
This is my netstat -tln:
tcp 0 0 :::8080 :::*
A listening socket that is bound to ::, i.e. any address IPv6 address (INADDR6_ANY), may or may not also listen to connections using IPv4. This depends from several things:
IPV6_V6ONLY socket option is set on the listening socket (by the program that created the socket). Linux-based operating systems and FreeBSD are examples of such operating systems.The default behavior if the option is not explicitly set by a program is OS dependent. On Linux-based operating systems, for example, you can change this default by writing 0 or 1 to /proc/sys/net/ipv6/bindv6only.
On some operating systems, the output of netstat will tell you whether the socket is dual-stack. FreeBSD's netstat reports dual-stack sockets as tcp46 and udp46 in the first column of the output, for examples.
Thanks for your answer @Johan Myreen I want to improve this answer with examples.
I am testing the ipv6_only behavior with both values.
1.
cat /proc/sys/net/ipv6/bindv6only
0
nc -6 -l 80
#server started
# netstat
tcp6 0 0 :::80 :::* LISTEN
# nc client
nc localhost 80
test
# server response
nc -6 -l 80
test
# from ipv6 now
nc ::1 80
test ipv6
# server response
nc -6 -l 80
test ipv6
2.
cat /proc/sys/net/ipv6/bindv6only
1
# server started
nc -6 -l 80
# connect to ipv4
nc localhost 80
nc: connect to localhost port 80 (tcp) failed: Connection refused
# connect to ipv6
nc ::1 80
test ipv6
# server respose
nc -6 -l 80
test ipv6
from above results we can see that value of /proc/sys/net/ipv6/bindv6only deciding the behaviour of ipv6 only or ipv6+ipv4