I am trying to have a jail <-> bridge <-> jail networking setup, and I thought I had something that should (in theory) work.
Below you can find my 2 jail configs, however it does not seem to work at all.
Below you can find my 2 jail configs, however it does not seem to work at all.
Code:
mount.devfs;
$p2pbridge = bridge100;
jail1 {
# Not sureif this is neccesary
exec.prestart = "";
exec.start = "";
exec.poststop = "";
exec.start = "/bin/sh /etc/rc";
exec.consolelog = "/var/log/jail_console_${name}.log";
$id = "4";
$epair = "epair${id}";
# dependencies
depend nginx;
# Networking
# This is just normal networking to get to the internet, ${bridge} is connected to the physical interface
exec.prestart += "ifconfig ${epair} create";
exec.prestart += "ifconfig ${bridge} addm ${epair}a";
exec.prestart += "dhclient ${epair}a";
exec.start += "ifconfig ${epair}b ether 02:cb:94:c4:54:9b";
exec.start += "dhclient ${epair}b";
exec.poststop += "ifconfig ${epair}a destroy";
#input network
exec.prestart += "ifconfig ${p2pbridge} create";
exec.prestart += "ifconfig epair100 create";
exec.prestart += "ifconfig ${p2pbridge} addm epair100b";
exec.start += "ifconfig epair100a ether 02:cb:94:c4:54:9b";
exec.poststop += "ifconfig epair100a destroy";
exec.poststop += "ifconfig ${p2pbridge} destroy";
host.hostname = jail1.local;
vnet;
vnet.interface = "${epair}b", "epair100a"; # Connect both interfaces, one going to the world and one for p2p between jails
path="/jail/jail1";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
# rest
allow.raw_sockets;
allow.sysvipc;
mount.procfs;
devfs_ruleset=11;
}
Code:
mount.devfs;
.include jail1.conf;
test {
# Not sureif this is neccesary
exec.prestart = "";
exec.start = "";
exec.poststop = "";
exec.start = "/bin/sh /etc/rc";
exec.consolelog = "/var/log/jail_console_${name}.log";
$id = "5";
$epair = "epair${id}";
# dependencies
depend jail1;
# Networking
exec.prestart += "ifconfig ${epair} create";
exec.prestart += "ifconfig ${p2pbridge} addm ${epair}a";
exec.start += "ifconfig ${epair}b ether 02:cb:94:c4:54:0b";
exec.poststop += "ifconfig ${epair}a destroy";
host.hostname = jail2.local;
vnet;
vnet.interface = "${epair}b"; # Other end of the connection, this should be connected to the p2p bridge
path="/jail/jail2";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.clean;
# rest
allow.raw_sockets;
allow.sysvipc;
mount.procfs;
devfs_ruleset=11;
}
While playing around, I have discovered that if I connect the jails directly with an epair, it does fully work. However, I would like to have multiple jails communicate to jail1, not just one. (and without having to create an epair for every connected jail). Therefore I thought a bridge would be perfect, it should be exactly how my existing jail communicate with the rest of my network, right?
However, I seem to be doing something wrong, and I don't know what. Could anyone help me figure this out?
However, I seem to be doing something wrong, and I don't know what. Could anyone help me figure this out?