Distribution de travail : FreeBSD 13.0/13.1
https://assistanz.com/running-web-server-database-server-in-freebsd-jail/
https://freebsdfoundation.org/freebsd-project/resources/introduction-to-freebsd-jails/
https://rderik.com/blog/running-a-web-server-on-freebsd-inside-a-jail/
https://www.reddit.com/r/freebsd/comments/uu5r8m/tutorial_how_to_create_a_jail_with_nat_forwarding/
[util01@station66 ~]$ sudo su
Password:
You have mail.
root@station66:/usr/home/util01 #
root@station66:/usr/home/util01 # sysrc cloned_interfaces="lo1"
cloned_interfaces: -> lo1
root@station66:/usr/home/util01 # service netif cloneup
Created clone interfaces: lo1.
root@station66:/usr/home/util01 # mkdir -p /jail/web.reseau01.local
root@station66:/usr/home/util01 # bsdinstall jail /jail/web.reseau01.local
Sélectionner le miroir par défaut
Sélectionner la distribution pas défaut
Après l'installation, choisir un mot de passe pour 'root' et créer un utilisateur.
root@station66:/usr/home/util01 # ifconfig
msk0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
options=c011a<TXCSUM,VLAN_MTU,VLAN_HWTAGGING,TSO4,VLAN_HWTSO,LINKSTATE>
ether 00:16:d3:65:58:d6
inet 192.168.1.66 netmask 0xffffff00 broadcast 192.168.1.255
media: Ethernet autoselect (100baseTX <full-duplex,flowcontrol,rxpause,txpause>)
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
Ici : msk0
Créer :
/etc/jail.conf
Ajouter :
path = "/usr/jail/${host.hostname}";
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
mount.devfs;
web_reseau01_local {
host.hostname = web.reseau01.local;
host.domainname = reseau01.local;
ip4.addr = 'lo1|127.0.1.11/32';
ip4.addr += 'msk0|192.168.1.211/32';
path = "/jail/web.reseau01.local";
}
Ouvrir :
/etc/rc.conf
Ajouter à la fin :
jail_enable="YES"
jail_list="web.reseau01.local"
root@station66:/usr/home/util01 # service jail start web.reseau01.local
Starting jails: web_reseau01_local.
root@station66:/usr/home/util01 #
root@station66:/usr/home/util01 # jls
JID IP Address Hostname Path
1 127.0.1.11 web.reseau01.local /jail/web.reseau01.local
root@station66:/usr/home/util01 #
root@station66:/usr/home/util01 # jexec 1 sh
#
# 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+http://pkg.FreeBSD.org/FreeBSD:13:amd64/quarterly, please wait...
Verifying signature with trusted certificate pkg.freebsd.org.2013102301... done
[web.reseau01.local] Installing pkg-1.18.3...
[web.reseau01.local] Extracting pkg-1.18.3: 100%
pkg: not enough arguments
Usage: pkg [-v] [-d] [-l] [-N] [-j <jail name or id>|-c <chroot path>|-r <rootdir>] [-C <configuration file>] [-R <repo config dir>] [-o var=value] [-4|-6] <command> [<args>]
For more information on available commands and options see 'pkg help'.
#
# pkg install sudo
# visudo
Chercher :
root ALL=(ALL) ALL
Ajouter après :
util01 ALL=(ALL) ALL
root@station66:/usr/home/util01 # ssh util01@192.168.1.211
...
Welcome to FreeBSD!
...
util01@web:~ $ sudo su
...
Password:
root@web:/usr/home/util01 #