Fixing internet access in jail

Hello
I have been struggling for days to get internet access in my jails. I wanted to use Bastille for creating jails (after manually creating one without). I followed quite a lot of tutorials step for step on setting up a jail, which seemed so easy, and yet I always ended up not being able to reach the internet from inside the jail.

I would try to install a package, but first had to install pkg, which always gave this error:
Code:
root@freeBSDjail:~ # pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+https://pkg.FreeBSD.org/FreeBSD:15:amd64/quarterly, please wait...
pkg: Error fetching https://pkg.FreeBSD.org/FreeBSD:15:amd64/quarterly/Latest/pkg.pkg: Transient resolver failure
A pre-built version of pkg could not be found for your system.
Bootstrapping pkg from pkg+https://pkg.FreeBSD.org/FreeBSD:15:amd64/kmods_quarterly_1, please wait...
pkg: Error fetching https://pkg.FreeBSD.org/FreeBSD:15:amd64/kmods_quarterly_1/Latest/pkg.pkg: Transient resolver failure
A pre-built version of pkg could not be found for your system.

The solution was changing the value in /etc/resolv.conf in the jail: from the localhost ip nameserver 127.0.0.1 to e.g. nameserver 9.9.9.9 or 1.1.1.1 or 8.8.8.8.

Then I exited the jail, and from the host restarted the jail. Since I am using bastille I used the following command # bastille restart jail_name

Then I could log into the jail again via: bastille console jail_name

and then I would get the following running # pkg
Code:
root@jail:~ # pkg
The package management tool is not yet installed on your system.
Do you want to fetch and install it now? [y/N]: y
Bootstrapping pkg from pkg+https://pkg.FreeBSD.org/FreeBSD:15:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
[freeBSDjail] Installing pkg-2.7.5...
[freeBSDjail] Extracting pkg-2.7.5: 100%

I am new to freeBSD, and I definitely have a lot more to learn about networking.

I just wanted to share in case, someone like me will stumble upon the same problem.

And if you sit with an explanation for why it works like this, or why it went bad for me, I would love to understand. And the same if you have a suggestion for networking101 which has been helpful to you.

All the best to you all, and thanks to the devs at freeBSD and bastille <3
 
I see that this thread has been moved to networking. Thank you mod. I edited the post, as I learned, that I only needed to change the /etc/resolv.conf in the jail, and not on the host.
 
Back
Top