# pkg_add -r not working inside brand-new jail



## sh4m1l65 (Mar 3, 2010)

(I'm Not sure whether to post this to Ports/Packages, or to Networking, but other networking appears to be working: I can ssh out to the Internet, ftp, etc. from my new jail, so I am hoping my problem is more closely related to ports/packages management).

I've recently created a new jail:


```
# zfs create zr1/jails/dc
# cd /usr/src
# make -j6 clean buildworld DESTDIR=/zr1/jails/dc SRCCONF=${ATTACHED_SRC_CONF_TXT}
# make installworld DESTDIR=/zr1/jails/dc SRCCONF=${ATTACHED_SRC_CONF_TXT}
# cd etc
# make distribution DESTDIR=/zr1/jails/dc SRCCONF=${ATTACHED_SRC_CONF_TXT}
# cat >> /etc/rc.conf <<EOT
jail_list="${jail_list} dc"
jail_dc_rootdir="/zr1/jails/dc"
jail_dc_hostname="dc.fbsd.w7tek.us"
jail_dc_ip="10.0.1.224"
jail_dc_interface="msk0"
jail_dc_devfs_enable="YES"
jail_dc_procfs_enable="YES"
EOT
# echo "nameserver 10.0.1.1" >> /zr1/jails/dc/etc/resolv.conf
# /etc/rc.d/jail start
```

It works, I can jexec a /bin/sh in there, and ftp to my account with my ISP.
But pkg_add -r doesn't work:

```
# pkg_add -r bash
Error: Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.0-release/Latest/bash.tbz: Can't open data connection
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.0-release/Latest/bash.tbz' by URL
```

and yet ftp the same URL does work:

```
# ftp ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-8.0-release/Latest/bash.tbz
Trying 204.152.184.73...
Connected to ftp.freebsd.org.
220 Welcome to freebsd.isc.org.
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
200 Switching to Binary mode.
250 Directory successfully changed.
250-If you're looking for one of the FreeBSD releases, please look in the
250-releases/${ARCH}/${RELNAME} directory, where ARCH = "alpha", "amd64",
250-"i386", "ia64", "pc98", or "sparc64" and RELNAME = the release
250-you're interested in, e.g. "7.1-RELEASE" or "8.0-RELEASE".
250 Directory successfully changed.
250 Directory successfully changed.
250-These are packages for the amd64 architecture.  Here are brief
250-descriptions of each subdirectory.
250-
250-  packages-6-stable:      Packages for FreeBSD-6-stable.
250-  packages-6.4-release:   Packages for FreeBSD 6.4-release.
250-  packages-7-stable:      Packages for FreeBSD-7-stable.
250-  packages-7.2-release:   Packages for FreeBSD 7.2-release.
250-  packages-7.3-release:   Packages for FreeBSD 7.3-release. (not yet available)
250-  packages-8-stable:      Packages for FreeBSD-8-stable.
250-  packages-8.0-release:   Packages for FreeBSD 8.0-release.
250-  packages-9-current:     Packages for FreeBSD-9-current.
250-
250-packages-*-release directories are built from the ports collection
250-shipped with the release, and are not updated thereafter.
250-
250-packages-*-stable and packages-*-current are updated roughly once a
250-week.
250-
250-Please see the file "../../dir.sizes" for the current size of each
250-directory.  In particular, mirroring thise directories will cause about
250-8GB of traffic per week from packages-?-stable and packages-?-current
250-updates.
250-
250-Older release package sets may be found at:
250-
250-ftp://ftp-archive.freebsd.org/pub/FreeBSD-Archive/ports/amd64/
250 Directory successfully changed.
250 Directory successfully changed.
250 Directory successfully changed.
local: bash.tbz remote: bash.tbz
229 Entering Extended Passive Mode (|||8926|).
150 Opening BINARY mode data connection for bash.tbz (927591 bytes).
100% |*************************************|   905 KB  148.32 KB/s    00:00 ETA
226 File send OK.
927591 bytes received in 00:06 (146.55 KB/s)
221 Goodbye.
```

I wonder whether anyone in this forum can suggest what I might have misconfigured in this jail, that prevents pkg_add -r working? I suspect the minimalist src.conf that I used to build the jail from source might have to do with it, but I really would like to stay minimal; maybe the only thing to do is to comment all of those WITHOUT_ lines out, and add them back one-by-one until pkg_add starts failing... assuming, that is, that it would work if I hadn't done the minimalist source build.

Thanks,
--Tk


----------



## DutchDaemon (Mar 3, 2010)

Can you try to fetch(1) that URL? That's what pkg_add uses.

Additional info:

```
One or more pkg-name arguments may be specified, each being either a file
     containing the package (these usually end with a ``.tbz'' suffix) or a
     URL pointing at a file available on an ftp site.  Thus you may extract
     files directly from their anonymous ftp locations (e.g. pkg_add
     ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/packages/shells/bash-1.14.7.tbz).
     Note: If you wish to use passive mode ftp in such transfers, set the
     variable FTP_PASSIVE_MODE to some value in your environment.  Otherwise,
     the more standard ACTIVE mode may be used.  If pkg_add consistently fails
     to fetch a package from a site known to work, it may be because you have
     a firewall that demands the usage of passive mode ftp.
```


----------



## sh4m1l65 (Mar 4, 2010)

*FTP_PASSIVE_MODE was my key*

DutchDaemon, thank you for your reco, including the additional info. Once I set FTP_PASSIVE_MODE=YES on the command line, pkg_add got over its inability to fetch into the jail. I suspect my firewall is doing its job 

Thanks again!
--Tk


----------



## sh4m1l65 (Mar 4, 2010)

*in other words, I didn't RTFM.*

Lesson learned (yet again). I see the relevant portion (quoted by DutchDaemon) from the manpage.

Thanks again,
--Tk


----------

