Replies: 3 comments 5 replies
-
👋 Hi @MickLesk, I always always thought that the information about the IP shall be more readily available. I really like the way you utilize the tags feature for this! Anyways I noticed that it takes some time and that the discovery does not work for all of my LXCs. , so I wanted to ask whether you considered using another approach to obtain the IPs, e.g. something like this ˛ My whole script looks like this #!/bin/bash
# Auto-detect node name
NODE=$(hostname)
# Print CSV header
echo "lxc_id,hostname,hwaddr,ipv4,ipv6,state"
# Process each container
for conf_file in /etc/pve/nodes/$NODE/lxc/*.conf; do
# Skip if no conf files exist
[[ -f "$conf_file" ]] || continue
lxc_id=$(basename "$conf_file" .conf)
# Get all info in one command
info=$(lxc-info -n "$lxc_id" -siH --config=lxc.uts.name --config=lxc.net.0.hwaddr 2>/dev/null)
# Parse the output
state=""
hostname=""
hwaddr=""
ipv4=""
ipv6=""
while IFS= read -r line; do
case "$line" in
"State:"*)
state=$(echo "$line" | cut -d: -f2- | tr -d ' ')
;;
"IP:"*)
# For IP lines, everything after "IP: " is the IP address
ip=$(echo "$line" | sed 's/^IP: *//')
# Determine if it's IPv4 or IPv6
if [[ "$ip" =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
ipv4="$ip"
else
# Anything else with colons is likely IPv6
ipv6="$ip"
fi
;;
"lxc.uts.name = "*)
hostname=$(echo "$line" | cut -d= -f2- | tr -d ' ')
;;
"lxc.net.0.hwaddr = "*)
hwaddr=$(echo "$line" | cut -d= -f2- | tr -d ' ')
;;
esac
done <<< "$info"
# Set defaults for missing values
[[ -z "$hostname" ]] && hostname="N/A"
[[ -z "$hwaddr" ]] && hwaddr="N/A"
# Output CSV row
printf "%s,%s,%s,%s,%s,%s\n" "$lxc_id" "$hostname" "$hwaddr" "$ipv4" "$ipv6" "$state"
done It used to be twice as fast before I asked Claude to include parsing of the # time scripts/new_getip.sh
lxc_id,hostname,hwaddr,ipv4,ipv6,state
101,tandoor,BC:24:11:40:5F:FD,10.10.7.60,fde3:538f:d15e:5778:be24:11ff:fe40:5ffd,RUNNING
104,unifi,72:24:95:08:05:68,10.10.7.7,fde3:538f:d15e:5778:7024:95ff:fe08:568,RUNNING
107,nginxproxymanager,96:17:7C:5E:DC:CB,10.10.7.91,fde3:538f:d15e:5778:9417:7cff:fe5e:dccb,RUNNING
110,jupyternotebook,BC:24:11:EA:7E:AA,10.10.7.176,,RUNNING
111,monica,BC:24:11:78:84:A8,10.10.7.208,fde3:538f:d15e:5778:be24:11ff:fe78:84a8,RUNNING
113,nextcloudpi,BC:24:11:A5:42:7D,10.10.7.190,fde3:538f:d15e:5778:be24:11ff:fea5:427d,RUNNING
real 0m0.089s
user 0m0.051s
sys 0m0.064s |
Beta Was this translation helpful? Give feedback.
-
the new script only adds a single tag. but before the update it was able to successfully update multiple ips. |
Beta Was this translation helpful? Give feedback.
-
Optimized
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
📘 IP-Tag Configuration Guide
The
IP-Tag
script automatically applies IP-based tags to LXC containers and VMs in Proxmox VE. This allows you to quickly identify machines by IP (or partial IP) directly in the Proxmox web UI.This guide explains:
📁 Configuration File
The config file is located at:
It contains all runtime settings and can be edited at any time. After editing, run:
to apply the changes.
⚙️ General Settings
TAG_FORMAT
last_two_octets
CIDR_LIST
LOOP_INTERVAL
300
FORCE_UPDATE_INTERVAL
7200
🔹 Example:
TAG_FORMAT
🔄 Update Intervals
VM_STATUS_CHECK_INTERVAL
600
LXC_STATUS_CHECK_INTERVAL
300
FW_NET_INTERFACE_CHECK_INTERVAL
900
🧠 Performance Tuning
These values control how aggressively and in parallel the script scans containers/VMs. Lower values = lower CPU.
🔧 VM Performance
VM_IP_CACHE_TTL
300
MAX_PARALLEL_VM_CHECKS
2–4
🔧 LXC Performance
LXC_IP_CACHE_TTL
300
LXC_STATUS_CACHE_TTL
300
LXC_BATCH_SIZE
3–5
MAX_PARALLEL_LXC_CHECKS
2–3
LXC_AGGRESSIVE_CACHING
true
LXC_SKIP_SLOW_METHODS
pct exec
andlxc-attach
fallback (less accurate)true
🧪 Example: Optimized Config for Homelab
📌 Manual Execution (no systemd required)
If you don’t want to run
iptag
as a service, you can run it manually at any time:The script is installed to:
🚫 Disabling the Service
To fully disable the background service:
Then use
iptag-run
whenever you want to apply tags.🪵 Log Output & Debugging
To avoid log spam, the service outputs minimal info. You can enable verbose logs for debugging:
Then run manually or restart the service.
🧩 Troubleshooting
LXC_BATCH_SIZE
,MAX_PARALLEL_*
, increase TTL valuesTAG_FORMAT
,CIDR_LIST
and IP detection logicRestart=always
📥 Support & Feedback
If you're using the community-scripts version of IP-Tag, please open issues or pull requests on GitHub.
You can also join the Discord server:
👉 https://discord.gg/UHrpNWGwkH
Beta Was this translation helpful? Give feedback.
All reactions