lftpでipv6で接続する

今どきftpに接続する必要が出てきた。ローカルでvsftpdのサーバーを立ててみた。

/etc//vsftpd/vsftpd.confのデフォルト値は以下のとなる。

# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=NO

# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=YES

つまり、ipv6でしか接続できないようになっている。

が、lftpで接続しようとすると、下記のようなエラーになってしまった。

 $ lftp

lftp :~> debug 9
lftp :~> open localhost6
---- Resolving host address...
---- IPv6 is not supported or configured
open: localhost6: No address found

 いろいろ調べても原因が分からず、lftpのソースコードをダウンロードして、キーワード「IPv6 is not supported or configured」で検索してみたら、以下のソースコードに辿りついた。

 bool Resolver::IsAddressFamilySupporded(int af)
{
#if INET6
    // check if ipv6 is really supported
    if(af==AF_INET6 && (!FindGlobalIPv6Address() || !CanCreateIpv6Socket()))
    {
       LogNote(4, "IPv6 is not supported or configured");
       return false;
    }
#endif // INET6
    return true;
}

赤字のメソッド名の詳細は分からないが、なんとなくグローバルIPipv6をサポートしないと、エラーになるように見える。

実は自宅のネット環境はipv4しかサポートしておらず、ipv6をサポートするネットワーク環境に接続してから、lftpを使うと 、エラーがなくなりました。