Does an IPv6 listener also accept IPv4 connections?

Does an IPv6 listener also accept IPv4 connections?

A management service on a dedicated server is configured to listen on IPv6, yet IPv4 clients can still connect. Another service also shows [::] but accepts only IPv6. The difference may lie not in the firewall, but in the IPV6_V6ONLY option set when the socket is created. Using the Linux network stack on Debian 13, we will reproduce both behaviors in an isolated environment, then apply the findings to a production listener audit—without changing public interfaces or existing SSH connections.

1. Distinguish the listening address from the access boundary

0.0.0.0 is the IPv4 wildcard address, and :: is the IPv6 wildcard address. The latter does not mean “IPv6 only”: on Linux, an AF_INET6 socket can accept IPv4 connections through IPv4-mapped addresses. The application may see the peer as ::ffff:127.0.0.1.

Setting IPV6_V6ONLY=1 blocks these mapped connections; setting it to 0 allows them. This option must be set before binding the address. The system default matters only when the application does not set the option explicitly, so a single kernel parameter cannot tell you how every service behaves.

A listening address describes where a socket is bound; it does not prove that the service is reachable from the public internet. Address configuration, routing, firewalls, and application authorization remain separate boundaries, each of which must be verified.

The IPv6 tests in this article use only loopback addresses. They do not imply that HttpNode provides public IPv6 addresses. Even if your workload uses only IPv4, do not skip checking local IPv6 listeners.

2. Record the actual process and effective configuration

Start by listing the two address families separately, so that a tool’s display format is not mistaken for evidence of protocol behavior:

sudo ss -lntp4
sudo ss -lntp6
sysctl net.ipv6.bindv6only
ip -brief address

Record the listening address, port, PID, and program name, then identify the service unit or container that started the process. If systemd manages it, check the relevant unit’s ExecStart, environment files, and application configuration. If socket activation is in use, also inspect ListenStream and BindIPv6Only in the corresponding .socket unit.

A program may create separate IPv4 and IPv6 sockets, or just one dual-stack socket. Listener listings provide clues, but connection tests are the final check. If the process runs in a container network namespace, the host’s listing may show only the forwarding entry point; inspect the listeners inside the container as well.

Redact credentials when recording this information, and do not copy a complete set of environment variables directly into a support ticket. Keep this stage read-only: do not stop services or change global defaults.

3. Reproduce both modes in a separate network namespace

Have iproute2 and Python 3 available. The following commands require administrative privileges and create a network namespace named hn-dualtest. Before running them, confirm that no other task is using that name. The new namespace has only a loopback interface, has no connection to the public internet, and leaves the existing address configuration untouched.

sudo ip netns add hn-dualtest
sudo ip -n hn-dualtest link set lo up
sudo ip netns exec hn-dualtest python3 - <<'PY'
import socket

cases = [
    (socket.AF_INET, ("127.0.0.1", 18080)),
    (socket.AF_INET6, ("::1", 18080)),
]

for only in (0, 1):
    for family, target in cases:
        with socket.socket(socket.AF_INET6, socket.SOCK_STREAM) as listener:
            listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
            listener.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, only)
            listener.bind(("::", 18080))
            listener.listen(4)
            listener.settimeout(1)
            actual = listener.getsockopt(
                socket.IPPROTO_IPV6, socket.IPV6_V6ONLY
            )
            with socket.socket(family, socket.SOCK_STREAM) as client:
                client.settimeout(1)
                try:
                    client.connect(target)
                except OSError as exc:
                    print(actual, family.name, "REJECT", exc.errno)
                else:
                    conn, peer = listener.accept()
                    with conn:
                        print(actual, family.name, "ACCEPT", peer[0])
PY
sudo ip netns del hn-dualtest

Here, 18080 is a test port, not a default port for any service. The program creates a fresh listener for each run so that the previous connection’s state cannot affect the next test. It also reads back the option that actually took effect.

The four results should appear in this order: with the option set to 0, both clients connect successfully; with it set to 1, IPv4 is rejected and IPv6 succeeds. The peer address reported for the first successful connection should use the IPv4-mapped format.

If creating the IPv6 socket itself fails, first check whether IPv6 is disabled in the test namespace. That failure does not establish that the production application accepts only IPv4. If the script exits unexpectedly, make sure no test processes remain before running the final namespace deletion command.

4. Apply the findings to the actual service

Define which address families the service needs

For a management interface that needs only local access, prefer binding explicitly to the required loopback address rather than a wildcard address. An IPv4-only application can use an AF_INET listener. If dual-stack access is genuinely required, explicitly choose between separate sockets and allowing mapped connections; do not rely on undocumented system defaults.

Changing net.ipv6.bindv6only does not retroactively alter existing listeners, and it may affect sockets that other programs create later. A safer scope for the change is a single service: save the original configuration, change the application option, check the syntax, and recreate the listener in a controlled manner. If a .socket unit owns the listener, restarting only the application process may not recreate the socket.

Verify that access controls cannot be bypassed

If the application compares source addresses as strings, check that it handles 127.0.0.1 and its IPv4-mapped form consistently. Do not simply strip an address prefix for “compatibility.” Use well-established address-parsing APIs and apply policies by address family and subnet.

IPv4 firewall rules do not automatically establish that IPv6 is protected. Check which address families the rules actually cover, then test from both permitted and prohibited sources. Do not temporarily disable the entire filtering ruleset just to make the test pass.

5. Complete restart acceptance with positive and negative tests

Verification must cover at least three points: the intended address families connect successfully, access paths that should be blocked actually fail, and the results remain consistent after the service’s listeners are recreated. After a successful connection, also check the application response to avoid mistaking another process on the same port for the intended service.

Local tests establish socket behavior; an independent client verifies the actual network path. A failed connection alone does not prove that IPV6_V6ONLY is taking effect: missing routes, filtering rules, and a service that is not running must also be ruled out. Without an actual IPv6 address or route, record only the local verification findings; do not claim that public dual-stack access has been validated.

Finally, archive the listener listings before and after the change, the service configuration diff, all four test results, and the independent client results. If unexpected rejections occur, restore the original configuration, recreate the listener, and verify again rather than repeatedly toggling global parameters and hoping for the right outcome. Listener management on a dedicated server should ultimately rest on an explicit address-family policy and repeatable connection evidence.

Frequently asked questions

Does a listener on [::] accept only IPv6?

Not necessarily. An AF_INET6 socket with IPV6_V6ONLY set to 0 can accept IPv4-mapped connections. Check application settings and test both address families.

Does changing net.ipv6.bindv6only update existing listeners?

No. It supplies a default when sockets are created, and applications may override it. Recreate the listener in a controlled change and verify the effective option and connections.

Dedicated AMD EPYC 7543P server, from $469/month

Configure an HttpNode Dedicated Server View HttpNode AMD rental plans and pricing

HttpNode Dedicated Servers, exclusively yours

Before configuring, check memory, storage, and network requirements. After delivery, view the server credentials in the console.