0

It used to be that you could force command line FTP to use IPv4 like so:

ftp -4 ftp.example.com

However, at some point in the relatively recent past the "-4" (and for that matter, the "-6") option seems to have been removed. Despite exhaustively searching the Web (even for the exact error "ftp: 4: unknown option") I can't find out how to, as the old man page reads, "Use only IPv4 to contact any host" and force use of IPv4. Instead I'm forced to wait for the client to time out on the IPv6 in the DNS before trying IPv4, which is waste of time.

Is there any other way to accomplish this?

And before I get lectured on the insecurity of FTP, I'm aware of that and my options. However, I'm connecting to a very old server with non-critical log-in credentials to retrieve non-sensitive data.

My ftp on Xubuntu 14.04 LTS supports the -4 option, but ftp on CentOS 7.7 doesn't.

  • 1
    What implementation of ftp are you using? What package does it come from on your Linux? (and what Linux are you running?) – Kusalananda Oct 7 '19 at 9:10
  • Sorry, I suppose I should have added that, but I thought it was overkill. My old Xubuntu desktop (14.04 LTS) has the now missing option. It's missing on CentOS 7.7 from the base repo. – CraigH Oct 7 '19 at 9:16
  • As a workaround, you might want to configure your DNS to prioritize ipv4 answers. askubuntu.com/questions/32298/… – Mark Plotnick Oct 7 '19 at 16:46
  • @MarkPlotnick Yes, I saw that answer in my research, but it wasn't my preference to make that kind of configuration change in some other system component. Thanks though. – CraigH Oct 7 '19 at 22:22
1

-4 and -6 are options added by a patch in the Debian version of netkit-ftp; you’ll find these available in any Debian derivative. Fedora, RHEL and CentOS don’t have an equivalent patch, so their ftp doesn’t support these options.

To force IPv4, you could try specifying the target IP address rather than the host name.

|improve this answer|||||
  • Oh, OK, interesting. I can't say I've used this a lot in the past, but I mostly use CentOS for server stuff, so I'm surprised that I'm yearning for a Debian-related quirk. And yes, I'd thought of using the IP address in the command, and I suppose I will do that, but I was trying to avoid that considering we have these things called domains! :) – CraigH Oct 7 '19 at 9:45
  • Yes, it’s not a great workaround... – Stephen Kitt Oct 7 '19 at 9:46
  • @CraigH maybe a two step workaround if the IP's likely to change - use dig or something to get the IPv4 address and then use the IP with ftp. – muru Oct 7 '19 at 9:52
  • @muru Yes, not unreasonable to suggest, but in my limited-use case before I decommission the old server I'd just use what's in the command-line history rather than complicating it with dig. However, potentially this is a good suggestion for others. Thanks. – CraigH Oct 7 '19 at 10:35

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.