17.6.VNET jail
最后更新于
vnet {
# 启动/日志记录
exec.consolelog = "/var/log/jail_console_${name}.log";
# 权限
allow.raw_sockets;
exec.clean;
mount.devfs;
devfs_ruleset = 5;
# 路径/主机名
path = "/usr/local/jails/containers/${name}";
host.hostname = "${name}";
# VNET/VIMAGE
vnet;
vnet.interface = "${epair}b";
# 网络/接口
$id = "154"; ①
$ip = "192.168.1.${id}/24";
$gateway = "192.168.1.1";
$bridge = "bridge0"; ②
$epair = "epair${id}";
# 添加到 bridge 接口
exec.prestart = "/sbin/ifconfig ${epair} create up";
exec.prestart += "/sbin/ifconfig ${epair}a up descr jail:${name}";
exec.prestart += "/sbin/ifconfig ${bridge} addm ${epair}a up";
exec.start += "/sbin/ifconfig ${epair}b ${ip} up";
exec.start += "/sbin/route add default ${gateway}";
exec.start += "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.poststop = "/sbin/ifconfig ${bridge} deletem ${epair}a";
exec.poststop += "/sbin/ifconfig ${epair}a destroy";
} exec.prestart += "jib addm ${name} em0";
exec.poststop += "jib destroy ${name}";
vnet.interface = "e0b_${name}"; exec.prestart += "jng bridge ${name} em0";
exec.poststop += "jng shutdown ${name}";
vnet.interface = "ng0_${name}";[devfsrules_jail_vnet_dhcp=101]
add include $devfsrules_jail_vnet
add path 'bpf*' unhide