diff --git a/lxc-iptag b/lxc-iptag index f6b4eec..a94fa56 100755 --- a/lxc-iptag +++ b/lxc-iptag @@ -96,6 +96,12 @@ fw_net_interface_changed() { update_lxc_iptags() { vmid_list=$(pct list 2>/dev/null | grep -v VMID | awk '{print $1}') for vmid in ${vmid_list}; do + # Check if the container ID is in the exclusion list + if [[ " ${EXCLUSION_LIST[*]} " == *" ${vmid} "* ]]; then + echo "Skipping ${vmid} as it is in the exclusion list" + continue + fi + last_tagged_ips=() current_valid_ips=() next_tags=() @@ -113,6 +119,12 @@ update_lxc_iptags() { # Get current IPs current_ips_full=$(lxc-info -n "${vmid}" -i | awk '{print $2}') for ip in ${current_ips_full}; do + # Check if the IP is in the exclusion list + if [[ " ${EXCLUSION_LIST[*]} " == *" ${ip} "* ]]; then + echo "Skipping IP ${ip} for container ${vmid} as it is in the exclusion list" + continue + fi + if is_valid_ipv4 "${ip}" && ip_in_cidrs "${ip}" "${CIDR_LIST[*]}"; then current_valid_ips+=("${ip}") next_tags+=("${ip}") diff --git a/lxc-iptag.conf b/lxc-iptag.conf index 8b1caf7..c012e04 100644 --- a/lxc-iptag.conf +++ b/lxc-iptag.conf @@ -7,3 +7,11 @@ LOOP_INTERVAL=60 FW_NET_INTERFACE_CHECK_INTERVAL=60 LXC_STATUS_CHECK_INTERVAL=-1 FORCE_UPDATE_INTERVAL=1800 + +# Exclusion list for IPs or container IDs +EXCLUSION_LIST=( + # Add IPs or container IDs here + # Example: + # 192.168.1.100 + # container_id_1 +)