mirror of
https://github.com/BastilleBSD/bastille.git
synced 2025-12-10 17:09:48 +01:00
add PATH; improve firewall
This commit is contained in:
@@ -94,9 +94,7 @@ First, create the loopback interface:
|
||||
```shell
|
||||
ishmael ~ # sysrc cloned_interfaces+=lo1
|
||||
ishmael ~ # sysrc ifconfig_lo1_name="bastille0"
|
||||
ishmael ~ # sysrc ifconfig_bastille0_aliases="inet 10.17.89.1/32"
|
||||
ishmael ~ # service netif cloneup
|
||||
ishmael ~ # ifconfig bastille0 inet 10.17.89.1/32
|
||||
```
|
||||
|
||||
Second, enable the firewall:
|
||||
@@ -116,7 +114,8 @@ set block-policy return
|
||||
scrub in on $ext_if all fragment reassemble
|
||||
|
||||
set skip on lo
|
||||
nat on $ext_if from bastille0:network to any -> ($ext_if)
|
||||
table <jails> persist
|
||||
nat on $ext_if from <jails> to any -> ($ext_if)
|
||||
|
||||
## rdr example
|
||||
## rdr pass inet proto tcp from any to any port {80, 443} -> 10.17.89.45
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
|
||||
|
||||
## root check first.
|
||||
bastille_root_check() {
|
||||
if [ $(id -u) -ne 0 ]; then
|
||||
|
||||
@@ -67,9 +67,9 @@ for _jail in ${JAILS}; do
|
||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -c ${_jail}
|
||||
|
||||
## update ${bastille_jail_loopback}:network with added/removed addresses
|
||||
## update table:jails in firewall with container address
|
||||
if [ ! -z ${bastille_jail_loopback} ]; then
|
||||
pfctl -f /etc/pf.conf
|
||||
pfctl -t jails -T add $(jls -j ${_jail} ip4.addr)
|
||||
fi
|
||||
fi
|
||||
echo
|
||||
|
||||
@@ -64,13 +64,14 @@ for _jail in ${JAILS}; do
|
||||
|
||||
## test if running
|
||||
elif [ $(jls name | grep -w "${_jail}") ]; then
|
||||
## remove ip4.addr from firewall table:jails
|
||||
if [ ! -z ${bastille_jail_loopback} ]; then
|
||||
pfctl -t jails -T delete $(jls -j ${_jail} ip4.addr)
|
||||
fi
|
||||
|
||||
## stop container
|
||||
echo -e "${COLOR_GREEN}[${_jail}]:${COLOR_RESET}"
|
||||
jail -f "${bastille_jailsdir}/${_jail}/jail.conf" -r ${_jail}
|
||||
|
||||
## update ${bastille_jail_loopback}:network with added/removed addresses
|
||||
if [ ! -z ${bastille_jail_loopback} ]; then
|
||||
pfctl -f /etc/pf.conf
|
||||
fi
|
||||
fi
|
||||
echo
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user