I noticed that my SSH session is not usable (random connection errors, hugh delay, etc.) when I'm connected by IPv6. I'm not connecting to my server by IPv4/IPv6 addresses directly. I use my domain name which has valid A and AAAA DNS records. I noticed that I get randomly connected by either IPv4 or IPv6.

A simple solution would be to just disbale IPv6 in the ssh config, but I think that's a dirty solution. I would rather know:

  1. Why get I connected by IPv4/IPv6 randomly.
  2. Why is only a session by IPv6 unstable?
  • 2
    We can't answer why with the information you've given us. The symptoms suggest that you are initially trying to connect via IPv6, timing out, and falling back to IPv4. You will need to investigate why IPv6 is not working (preferably with packet captures) in order to eliminate the delays/issues/etc. – Andrew B Jun 17 '16 at 3:02

ssh's -6 parameter forces the client to connect with IPv6: ssh -6 hostname

It is possible to stop sshd from listening on IPv6 but that would simply cause an error instead of your slow connection problem.

The exact reason why your connection alternates randomly between the two may be hard (and pointless) to pinpoint, but is probably related to the results (possibly their order) received by the DNS servers and local DNS caching.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.