Skip to content

Allow specifying IPv4 or IPv6 _only_ on connect #770

Open

Description

@bitprophet

User weylin on Freenode encountered an issue (via Fabric) where:

  • The hostname resolution is returning IPv6 before IPv4;
  • IPv6 address is technically connectable (no resolution, connection or timeout errors occur);
  • But network filtering prevents actual SSH-level connections from occurring (resulting in exceptions at the banner step).

It's possible this means the spot where we raise the banner error should be more rigorous about what's going on. But the requested change - and the one that's easier to implement and probably solves a whole host of edge cases like this one - was for tighter control over which address families are used when connecting.

(Side note: it's possible for users to work around this by passing in the IPv4 address explicitly instead of the hostname, e.g. using socket.gethostbyname(name) which tends to return IPv4 only. But it's probably still more elegant to implement a 'fix' by the below...)

Should probably not be hard to update Client._families_and_addresses (and connect, and Fabric's connect) so they take a kwarg or two specifying IPv4 only / IPv6 only, which then in _families_and_addresses causes the loop (or maybe the getaddrinfo call itself) to omit one family or the other.

Slightly related is #686, insofar as it's another probably easily changed/fixed issue in the same area.

Activity

  1. added this to the milestone on Jul 2, 2016
  2. modified the milestones: 2.2, on Aug 16, 2017
  3. modified the milestones: , p2 on Oct 16, 2018
  4. fuzzy76 commented on Apr 29, 2022

    @fuzzy76

    A good start would be to support the AddressFamily directive in ssh_config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions