mirror of
https://github.com/hackacad/bastille.git
synced 2025-12-22 18:21:53 +01:00
add support for static MAC on VNET jails
- support static MAC on bridged and VNET jails - remove quotes around vnet.interface
This commit is contained in:
@@ -94,14 +94,13 @@ generate_vnet_jail_netblock() {
|
|||||||
local uniq_epair="bastille0"
|
local uniq_epair="bastille0"
|
||||||
local uniq_epair_bridge="0"
|
local uniq_epair_bridge="0"
|
||||||
fi
|
fi
|
||||||
# generate static MAC for jail using host prefix (first half of host MAC)
|
local host_mac_prefix="$(ifconfig ${external_interface} | grep ether | awk '{print $2}' | cut -d':' -f1-3)"
|
||||||
local host_mac_prefix="$(ifconfig ${external_interface} | grep ether | awk '{print $2}' | cut -d':' -f1-3)"
|
local jail_mac_suffix="$(echo -n ${jail_name} | sha256 | tr -d '\n' | awk '{print substr($0,length($0)-5,2) ":" substr($0,length($0)-3,2) ":" substr($0,length($0)-1,1)}')"
|
||||||
local jail_mac_suffix="$(echo -n ${jail_name} | sha256 | tr -d '\n' | awk '{print substr($0,length($0)-5,2) ":" substr($0,length($0)-3,2) ":" substr($0,length($0)-1,1)}')"
|
|
||||||
if [ -n "${use_unique_bridge}" ]; then
|
if [ -n "${use_unique_bridge}" ]; then
|
||||||
## generate bridge config
|
## generate bridge config
|
||||||
cat <<-EOF
|
cat <<-EOF
|
||||||
vnet;
|
vnet;
|
||||||
vnet.interface = "e${uniq_epair_bridge}b_${jail_name}";
|
vnet.interface = e${uniq_epair_bridge}b_${jail_name};
|
||||||
exec.prestart += "ifconfig epair${uniq_epair_bridge} create";
|
exec.prestart += "ifconfig epair${uniq_epair_bridge} create";
|
||||||
exec.prestart += "ifconfig ${external_interface} addm epair${uniq_epair_bridge}a";
|
exec.prestart += "ifconfig ${external_interface} addm epair${uniq_epair_bridge}a";
|
||||||
exec.prestart += "ifconfig epair${uniq_epair_bridge}a up name e${uniq_epair_bridge}a_${jail_name}";
|
exec.prestart += "ifconfig epair${uniq_epair_bridge}a up name e${uniq_epair_bridge}a_${jail_name}";
|
||||||
@@ -117,9 +116,9 @@ EOF
|
|||||||
vnet;
|
vnet;
|
||||||
vnet.interface = e0b_${uniq_epair};
|
vnet.interface = e0b_${uniq_epair};
|
||||||
exec.prestart += "jib addm ${uniq_epair} ${external_interface}";
|
exec.prestart += "jib addm ${uniq_epair} ${external_interface}";
|
||||||
exec.prestart += "ifconfig e0a_${uniq_epair} description \"vnet host interface for Bastille jail ${jail_name}\"";
|
|
||||||
exec.prestart += "ifconfig e0a_${uniq_epair} ether ${host_mac_prefix}:${jail_mac_suffix}a";
|
exec.prestart += "ifconfig e0a_${uniq_epair} ether ${host_mac_prefix}:${jail_mac_suffix}a";
|
||||||
exec.prestart += "ifconfig e0b_${uniq_epair} ether ${host_mac_prefix}:${jail_mac_suffix}b";
|
exec.prestart += "ifconfig e0b_${uniq_epair} ether ${host_mac_prefix}:${jail_mac_suffix}b";
|
||||||
|
exec.prestart += "ifconfig e0a_${uniq_epair} description \"vnet host interface for Bastille jail ${jail_name}\"";
|
||||||
exec.poststop += "jib destroy ${uniq_epair}";
|
exec.poststop += "jib destroy ${uniq_epair}";
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user