pkg_add -r Troubleshooting

Hello all--

I recently installed FreeBSD out of both need and a simple desire to understand Unix better. One problem that I seem unable to solve is getting pkg_add -r to work for me.

I've read over and over again in the cloud that my problem is related to ftp passive mode-- which I have attempted to remedy both by doing:

Code:
$ftp
$ftp>passive

to toggle passive mode and:

Code:
set FTP_PASSIVE_MODE=true //or//
set FTP_PASSIVE_MODE="YES"

to no general success...

The following is the output of verbose pkg_add:

Code:
$ sudo pkg_add -vr apache
scheme:   [ftp]
user:     []
password: []
host:     [ftp.freebsd.org]
port:     [0]
document: [/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/apache.tbz]
---> ftp.freebsd.org:21
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
<<< 220 Welcome to freebsd.isc.org.
>>> USER anonymous
<<< 331 Please specify the password.
>>> PASS xxxxxx
<<< 230 Login successful.
>>> PWD
<<< 257 "/"
>>> CWD pub/FreeBSD/ports/i386/packages-8.0-release/Latest
<<< 250 Directory successfully changed.
>>> MODE S
<<< 200 Mode set to S.
>>> TYPE I
<<< 200 Switching to Binary mode.
binding data socket
>>> PORT 128,101,135,195,228,234
<<< 200 PORT command successful. Consider using PASV.
initiating transfer
>>> RETR apache.tbz
<<< 425 Failed to establish connection.
Error: Unable to get [url]ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/apache.tbz:[/url] Can't open data connection
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/apache.tbz' by URL
pkg_add: 1 package addition(s) failed

I'd rather not have to port install every application I need...
 
Sudo strips variables from the environment. Sudo first, then set FTP_PASSIVE_MODE and then do a pkg_add -r.
 
So something like:

Code:
$ su
Password:
x-128-101-135-195# set FTP_PASSIVE_MODE=true
x-128-101-135-195# pkg_add -vr apache
scheme:   [ftp]
user:     []
password: []
host:     [ftp.freebsd.org]
port:     [0]
document: [/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/apache.tbz]
---> ftp.freebsd.org:21
looking up ftp.freebsd.org
connecting to ftp.freebsd.org:21
<<< 220 Welcome to freebsd.isc.org.
>>> USER anonymous
<<< 331 Please specify the password.
>>> PASS xxxxxx
<<< 230 Login successful.
>>> PWD
<<< 257 "/"
>>> CWD pub/FreeBSD/ports/i386/packages-8.0-release/Latest
<<< 250 Directory successfully changed.
>>> MODE S
<<< 200 Mode set to S.
>>> TYPE I
<<< 200 Switching to Binary mode.
binding data socket
>>> PORT 128,101,135,195,208,104
<<< 200 PORT command successful. Consider using PASV.
initiating transfer
>>> RETR apache.tbz
<<< 425 Failed to establish connection.
Error: Unable to get [url]ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/apache.tbz:[/url] Can't open data connection
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/apache.tbz' by URL
pkg_add: 1 package addition(s) failed
 
What shell are you using?

If it's the standard csh you will have to use setenv:
[cmd=]setenv FTP_PASSIVE_MODE[/cmd]

NB you can use % sudo -s instead of su. Only members of the wheel group are allowed to use su.
 
Let's see here:

My shell--

Code:
$ echo $SHELL
/bin/sh

Attempting sudo -s and setenv FTP_PASSIVE_MODE--

Code:
$ sudo -s
# setenv FTP_PASSIVE_MODE
setenv: not found
#
 
Solved the problem, thanks for the help SirDice...

The correct command after sudo -s was:

Code:
export FTP_PASSIVE_MODE=true
 
Hello,

I did follow the tutorial, but It seems that It did not worked for me.

here is the error:
Code:
pkg_add -rv sudo
scheme:   [ftp]
user:     []
password: []
host:     [ftp.freebsd.org]
port:     [0]
document: [/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/sudo.tbz]
---> ftp.freebsd.org:21
looking up ftp.freebsd.org
Error: Unable to get [url]ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/sudo.tbz:[/url] No address record
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/sudo.tbz' by URL
pkg_add: 1 package addition(s) failed
and I have internet connection on the server. Any ideas are much appreciated. Thanks in advance.
 
Thank you for you replay.

Actually my resolv.conf seems to work because I able to connect to the outside.

Code:
> cat /etc/resolv.conf
search domain 
nameserver my ISP
nameserver my ISP

also this time the error message is different

Code:
<<< 425 Can't build data connection: Operation timed out.
Error: Unable to get [url]ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/sudo.tbz:[/url] Can't open data connection
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-8.0-release/Latest/sudo.tbz' by URL
pkg_add: 1 package addition(s) failed

I did check the pkg_add for the right path to the ftp. It use to work, but as soon as I apply nat rules with ipf it stop works.
Thank you very much for you time. If I find a solution I will post it. Thanks again.
 
It's resolved, It was firewall issue. I had port 21 open but It didn't allowed to go out to the freebsd ftp,Thanks.
 
Back
Top