From 6ded48163573ea0de5df5260fae71064afdfeec8 Mon Sep 17 00:00:00 2001 From: tschettervictor Date: Sat, 13 Dec 2025 22:01:31 -0700 Subject: [PATCH] create: fix ip6 and ip4 --- usr/local/share/bastille/common.sh | 5 ++++- usr/local/share/bastille/create.sh | 35 ++++++++++-------------------- 2 files changed, 15 insertions(+), 25 deletions(-) diff --git a/usr/local/share/bastille/common.sh b/usr/local/share/bastille/common.sh index 7d7f95c3..d11dcf9d 100644 --- a/usr/local/share/bastille/common.sh +++ b/usr/local/share/bastille/common.sh @@ -361,10 +361,13 @@ validate_ip() { fi info "\nValid IP: ${ip6}" export IP6_ADDR="${ip6}" - elif [ "${ip}" = "inherit" ] || [ "${ip}" = "ip_hostname" ] || [ "${ip}" = "0.0.0.0" ] || [ "${ip}" = "DHCP" ] || [ "${ip}" = "SYNCDHCP" ]; then + elif [ "${ip}" = "inherit" ] || [ "${ip}" = "ip_hostname" ]; then info "\nValid IP: ${ip}" export IP4_ADDR="${ip}" export IP6_ADDR="${ip}" + elif [ "${ip}" = "0.0.0.0" ] || [ "${ip}" = "DHCP" ] || [ "${ip}" = "SYNCDHCP" ]; then + info "\nValid IP: ${ip}" + export IP4_ADDR="${ip}" elif [ -n "${ip4}" ]; then if [ "${vnet_jail}" -eq 1 ]; then if [ -z "${subnet}" ]; then diff --git a/usr/local/share/bastille/create.sh b/usr/local/share/bastille/create.sh index 2f41e0bb..47f536ec 100644 --- a/usr/local/share/bastille/create.sh +++ b/usr/local/share/bastille/create.sh @@ -137,14 +137,12 @@ define_ips() { elif ifconfig | grep -qwF "${IP4_ADDR}"; then warn "[WARNING]: IP address in use: ${IP4_ADDR}" fi - local ipx_addr="ip4.addr" fi if [ -n "${IP6_ADDR}" ]; then if [ "${IP6_ADDR}" = "SLAAC" ] && [ "${VNET_JAIL}" -eq 0 ]; then error_exit "[ERROR]: Unsupported IP option for standard jail: ${IP6_ADDR}" fi - local ipx_addr="ip6.addr" fi # Set interface value @@ -170,37 +168,26 @@ define_ips() { IP4_DEFINITION="ip4 = ${IP4_ADDR};" IP6_DEFINITION="" IP6_MODE="disable" + IP6_ADDR="" fi elif [ "${IP4_ADDR}" = "ip_hostname" ]; then if [ "${DUAL_STACK}" -eq 1 ]; then - IP_HOSTNAME="${IP4_ADDR}" - IP4_DEFINITION="${IP_HOSTNAME};" - IP6_DEFINITION="${IP_HOSTNAME};" + IP4_DEFINITION="${IP4_ADDR};" + IP6_DEFINITION="${IP6_ADDR};" IP6_MODE="new" else - IP_HOSTNAME="${IP4_ADDR}" - IP4_DEFINITION="${IP_HOSTNAME};" + IP4_DEFINITION="${IP4_ADDR};" IP6_DEFINITION="" IP6_MODE="disable" + IP6_ADDR="" fi - elif [ "${ip}" = "DHCP" ] || [ "${ip}" = "SLAAC" ] || [ "${ip}" = "0.0.0.0" ]; then - if [ "${VNET_JAIL}" -eq 1 ]; then - if [ "${ipx_addr}" = "ip4.addr" ]; then - IP4_ADDR="${ip}" - elif [ "${ipx_addr}" = "ip6.addr" ]; then - IP6_ADDR="${ip}" - fi - else - error_exit "[ERROR]: Unsupported IP option for standard jail: ${ip}" + elif [ "${VNET_JAIL}" -eq 0 ]; then + if [ -n "${IP4_ADDR}" ]; then + IP4_DEFINITION="ip4.addr = ${bastille_jail_conf_interface}|${IP4_ADDR};" fi - else - if [ "${VNET_JAIL}" -eq 0 ]; then - if [ "${ipx_addr}" = "ip4.addr" ]; then - IP4_DEFINITION="${ipx_addr} = ${bastille_jail_conf_interface}|${IP4_ADDR};" - elif [ "${ipx_addr}" = "ip6.addr" ]; then - IP6_DEFINITION="${ipx_addr} = ${bastille_jail_conf_interface}|${IP6_ADDR};" - IP6_MODE="new" - fi + if [ -n "${IP6_ADDR}" ]; then + IP6_DEFINITION="ip6.addr = ${bastille_jail_conf_interface}|${IP6_ADDR};" + IP6_MODE="new" fi fi }