Solved VNET Jail unable to ping 1.1.1.1

I setup a jail with bsdinstall jail /jails/myjail as in https://freebsdfoundation.org/freebsd-project/resources/introduction-to-freebsd-jails, and setup the /etc/jail.conf contains the following
Code:
myjail {
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.consolelog = "/var/log/jail_console_${name}.log";

allow.raw_sockets;
exec.clean;
mount.devfs;
devfs_ruleset = 5;

path = "/jails/myjail";
host.hostname = "${name}";


$id = "154";
$ip = "192.168.1.${id}/24";
$gateway = "192.168.1.1";
$bridge = "bridge0";
$epair = "epair${id}";

vnet;
vnet.interface = "${epair}b";

exec.prestart  = "/sbin/ifconfig ${epair} create up";
exec.prestart += "/sbin/ifconfig ${epair}a inet $ip 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.poststop = "/sbin/ifconfig ${bridge} deletem ${epair}a";
exec.poststop += "/sbin/ifconfig ${epair}a destroy";
}
like in https://docs.freebsd.org/en/books/handbook/jails/#creating-vnet-jail
but when I run enter the jail with jexec, and try to test network with ping 1.1.1.1, I get host unreachable error.

my network configuration is:
Code:
ifconfig bridge create
ifconfig bridge0 addm re0
ifconfig bridge0 up
note re0 is my network card.
 
After some more test I got it to work, with still some problems.
With /etc/jail.conf being set to:
Code:
myjail {
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.consolelog = "/var/log/jail_console_${name}.log";

allow.raw_sockets;
exec.clean;
mount.devfs;
devfs_ruleset = 5;

path = "/jails/myjail";
host.hostname = "${name}";


$id = "154";
$ip = "192.168.0.${id}/24";
$gateway = "192.168.0.1";
$bridge = "bridge0";
$epair = "epair${id}";

vnet;
vnet.interface = "${epair}b";

exec.prestart  = "/sbin/ifconfig ${epair} create up";
exec.prestart += "/sbin/ifconfig ${epair}a inet $ip 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.poststop = "/sbin/ifconfig ${bridge} deletem ${epair}a";
exec.poststop += "/sbin/ifconfig ${epair}a destroy";
}
and the bridge being set to ifconfig bridge0 inet 192.168.0.250/24 addm re0 addm epair154a up
 
Back
Top