diff --git a/docs/chapters/networking.rst b/docs/chapters/networking.rst index da90a9e1..4f59456f 100644 --- a/docs/chapters/networking.rst +++ b/docs/chapters/networking.rst @@ -38,6 +38,10 @@ different types of jail network configurations. bastille will simply set ``ip4`` to ``ip_hostname`` inside the jail config. The jail will then function according the jail(8) documentation. +You cannot use ``-V|--vnet`` with any interface that is already a member of another +bridge. For example, if you create a bridge, and assign ``vtnet0`` as a member, you +will not be able to use ``vtnet0`` with ``-V|--vnet``. + IP Address Options ------------------ diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index 95f6b6af..272f69e1 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -179,10 +179,16 @@ validate_netif() { local LIST_INTERFACES="$(ifconfig -l)" - if echo "${LIST_INTERFACES} VNET" | grep -qwo "${INTERFACE}"; then - info "\nValid: (${INTERFACE})." - else + if ! echo "${LIST_INTERFACES} VNET" | grep -qwo "${INTERFACE}"; then error_exit "[ERROR]: Invalid: (${INTERFACE})." + elif [ -n "${VNET_JAIL}" ] && [ -z "${VNET_JAIL_BRIDGE}" ]; then + for _bridge in $(ifconfig -g bridge | grep -vw "${INTERFACE}bridge"); do + if ifconfig ${_bridge} | grep "member" | grep -owq "${INTERFACE}"; then + error_exit "[ERROR]: Interface (${INTERFACE}) is already a member of bridge: ${_bridge}" + fi + done + else + info "\nValid: (${INTERFACE})." fi } diff --git a/usr/local/share/bastille/setup.sh b/usr/local/share/bastille/setup.sh index b18e2518..07218e09 100644 --- a/usr/local/share/bastille/setup.sh +++ b/usr/local/share/bastille/setup.sh @@ -182,7 +182,6 @@ configure_shared_interface() { configure_bridge() { _auto_if="${1}" - _bridge_name="bastillebridge" _interface_list="$(ifconfig -l)" _interface_count=0 @@ -214,12 +213,13 @@ configure_bridge() { _interface_select="${_auto_if}" fi # Create bridge and persist on reboot + _bridge_name="${_interface_select}bridge" ifconfig bridge0 create - ifconfig bridge0 name bastillebridge - ifconfig bastillebridge addm ${_interface_select} up + ifconfig bridge0 name ${_bridge_name} + ifconfig ${_bridge_name} addm ${_interface_select} up sysrc cloned_interfaces+="bridge0" - sysrc ifconfig_bridge0_name="bastillebridge" - sysrc ifconfig_bastillebridge="addm ${_interface_select} up" + sysrc ifconfig_bridge0_name="${_bridge_name}" + sysrc ifconfig_${_bridge_name}="addm ${_interface_select} up" info "\nBridge interface successfully configured: [${_bridge_name}]" else