PrintLogo

Setting Passive Mode for Perl/CPAN




One problem with the default install of the CPAN shell is that if you need passive FTP to get through your firewall, the CPAN shell won't work. Here is the behavior:

.
.
.
Invalid PORT.
Retrying.
--12:26:05--  ftp://ftp.perl.org/pub/CPAN/authors/01mailrc.txt.gz
(try: 8) => `-'
Connecting to ftp.perl.org[192.35.244.50]:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/CPAN/authors ... done.
==> PORT ... 
Invalid PORT.
Retrying.

Locate libnet.cfg. For us, it is here:

/usr/lib/perl5/site_perl/5.8.0/Net/libnet.cfg

Edit the file so that the ftp_int_passiveline is:

{
'ftp_int_passive' => 1,
'snpp_hosts' => [],
'inet_domain' => undef,
'test_exist' => 1,
'ftp_testhost' => undef,
'daytime_hosts' => [],
'ph_hosts' => [],
'time_hosts' => [],
'smtp_hosts' => [],
'test_hosts' => 1,
'nntp_hosts' => [],
'pop3_hosts' => [],
}

For good measure, we also changed our environment:

root@srv-1 root # export FTP_PASSIVE=1
root@srv-1 root # set | grep FTP_PA
FTP_PASSIVE=1

Might as well add that to /etc/profile. Now:

root@srv-1 root # perl -MCPAN -e shell
.
.
.
Going to read /root/.cpan/sources/authors/01mailrc.txt.gz
LWP not available
Fetching with Net::FTP:
ftp://archive.progeny.com/CPAN/modules/02packages.details.txt.gz
Going to read /root/.cpan/sources/modules/02packages.details.txt.gz
Database was generated on Sun, 08 Jun 2003 09:14:27 GMT
HTTP::Date not available
There's a new CPAN.pm version (v1.70) available!
[Current version is v1.61]
You might want to try
install Bundle::CPAN
reload cpan
without quitting the current session. It should be a seamless upgrade
while we are running...

Well, that is better.



This article comes from NetAdminTools:
http://www.netadmintools.com/

The URL for this story is:
http://www.netadmintools.com/art273.html

Copyright 1997-2008 NetAdminTools.com. Read our Terms of Use.