- (djm) Only listen for IPv6 connections on AF_INET6 sockets; patch from
tsr2600 AT gmail.com
diff --git a/sshd.c b/sshd.c
index 9019411..27c38ba 100644
--- a/sshd.c
+++ b/sshd.c
@@ -976,6 +976,16 @@
&on, sizeof(on)) == -1)
error("setsockopt SO_REUSEADDR: %s", strerror(errno));
+#ifdef IPV6_V6ONLY
+ /* Only communicate in IPv6 over AF_INET6 sockets. */
+ if (ai->ai_family == AF_INET6) {
+ if (setsockopt(listen_sock, IPPROTO_IPV6, IPV6_V6ONLY,
+ &on, sizeof(on)) == -1)
+ error("setsockopt IPV6_V6ONLY: %s",
+ strerror(errno));
+ }
+#endif
+
debug("Bind to port %s on %s.", strport, ntop);
/* Bind the socket to the desired port. */