eBPF XDP hook presence
Commande de Contrôle :
ip link show dev $TARGET_IFACE | grep -E 'xdp|prog'État Cible Attendu : Interface displays xdp mode with active program id.
Attache des programmes eBPF XDP et Traffic Control directement au niveau pilote de la carte réseau (NIC) pour rejeter tout trafic entrant et sortant en microsecondes, tout en préservant un port de gestion chiffré dédié à la forensique.
export TARGET_IFACE=$(ip route get 8.8.8.8 | awk '{print $5; exit}')export FORENSIC_IP="10.240.0.99"echo "Isolating $TARGET_IFACE while pinning forensic link to $FORENSIC_IP"Target interface and forensic IP pinned.cat << 'EOF' > /tmp/xdp_quarantine.c#include <linux/bpf.h>#include <linux/if_ether.h>#include <linux/ip.h>#include <bpf/bpf_helpers.h>
SEC("xdp")int xdp_drop_all(struct xdp_md *ctx) { void *data = (void *)(long)ctx->data; void *data_end = (void *)(long)ctx->data_end; struct ethhdr *eth = data; if ((void *)(eth + 1) > data_end) return XDP_PASS; if (eth->h_proto != __constant_htons(ETH_P_IP)) return XDP_DROP; struct iphdr *iph = (void *)(eth + 1); if ((void *)(iph + 1) > data_end) return XDP_DROP; // Whitelist forensic management IP (10.240.0.99 = 0x6300f00a) if (iph->saddr == 0x6300f00a || iph->daddr == 0x6300f00a) return XDP_PASS; return XDP_DROP;}char _license[] SEC("license") = "GPL";EOFclang -O2 -target bpf -c /tmp/xdp_quarantine.c -o /tmp/xdp_quarantine.oip link set dev $TARGET_IFACE xdp obj /tmp/xdp_quarantine.o sec xdpXDP program loaded and active on interface.tc qdisc add dev $TARGET_IFACE clsact 2>/dev/null || truetc filter add dev $TARGET_IFACE egress bpf da obj /tmp/xdp_quarantine.o sec xdpTC egress filter successfully attached.eBPF XDP hook presence
Commande de Contrôle :
ip link show dev $TARGET_IFACE | grep -E 'xdp|prog'État Cible Attendu : Interface displays xdp mode with active program id.
Non-forensic packet drop counter
Commande de Contrôle :
bpftool prog tracelog | head -n 10État Cible Attendu : Continuous XDP_DROP events on all untrusted IP packets.
Validation : Verify standard network latency and ping return to baseline via ping -c 3 8.8.8.8