Files
2026-05-02 02:30:12 -07:00

21 lines
447 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
IFACE="${IMDS_DUMMY_INTERFACE:-imds-dummy}"
ADDR="${IMDS_LINK_LOCAL_ADDRESS:-169.254.169.254/32}"
if ! command -v ip >/dev/null 2>&1; then
echo "ip command is required" >&2
exit 1
fi
if ! ip link show "$IFACE" >/dev/null 2>&1; then
ip link add dev "$IFACE" type dummy
fi
if ! ip addr show dev "$IFACE" | grep -q "169.254.169.254"; then
ip addr add "$ADDR" dev "$IFACE"
fi
ip link set "$IFACE" up