"Address in use error" when starting IPv6 listener on port with started IPv4 listener

Hi!

I have a rather confusing issue with OpenWrt 22.03.2 r19803-9a599fee93 (Linksys WRT3200ACM) because when I start a IPv4 Listener on an abritary port ...

/usr/bin/socat TCP4-LISTEN:1234,fork,reuseaddr TCP4:127.0.0.1:5678 &

... netstat/lsof shows that there is only an IPv4 listener for port 1234:

root@xxx:~# netstat -anp | grep LISTEN | grep 1234
tcp        0      0 0.0.0.0:1234            0.0.0.0:*               LISTEN      9730/socat
root@xxx:~# lsof | grep 1234
socat     9730                     root    5u     IPv4      21728      0t0        TCP *:1234 (LISTEN)

But if I want to start an IPv6 listener ...

/usr/bin/socat TCP6-LISTEN:1234,fork,reuseaddr TCP4:127.0.0.1:5678
2023/02/14 17:46:08 socat[10049] E bind(5, {AF=10 [0000:0000:0000:0000:0000:0000:0000:0000]:1234}, 28): Address in use

... I do receive error "Address in use". According to my humble understanding this shouldn't happen at all!

So even if I confiugre e.g. uhttpd to listen on 0.0.0.0:80 only ...

# netstat -anp | grep LISTEN | grep :80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      10286/uhttpd

... staring an IPv6 listener on port 80 fails:

#  /usr/bin/socat TCP6-LISTEN:80,fork,reuseaddr TCP4:127.0.0.1:5678
2023/02/14 17:51:11 socat[10430] E bind(5, {AF=10 [0000:0000:0000:0000:0000:0000:0000:0000]:80}, 28): Address in use

Someone else observing this beahviour? Any advice if I'm doing something wrong?

Thanks

Add …,ipv6only=1 to the TCP6 listen spec. Without it, the IPv6 listener socket will be dual stack, supporting IPv4 clients through v6 mapped addresses.

2 Likes

More information:

For the whole system:

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.