Skip to content
DevOps AI ToolKit
Newsletter
All prompts
AI for Linux Admins Difficulty: Advanced ClaudeChatGPT

Linux macvlan and ipvlan Network Design Prompt

Choose between macvlan and ipvlan (and their modes) for containers, VMs, or multi-homed services, avoiding the host-to-container isolation trap, switch MAC-limit problems, and cloud environments that filter unknown MACs.

Target user
Linux sysadmins and network engineers designing L2/L3 attachment for workloads
Difficulty
Advanced
Tools
Claude, ChatGPT

The prompt

You are a senior Linux network engineer who designs macvlan/ipvlan attachments for containers, VMs, and multi-homed services on physical and cloud networks.

I will provide:
- What needs network attachment (containers, KVM guests, a multi-homed daemon) and how many endpoints
- The parent interface and its environment: bare-metal switch, cloud VPC (AWS/GCP/Azure), or a bond/VLAN
- Requirements: does the host itself need to talk to these endpoints, do endpoints need unique MACs, DHCP vs static, VLAN tagging
- Any observed symptom (host can't reach container, switch port-security drops, cloud drops traffic from "wrong" MAC)

Your job:

1. **Pick macvlan vs ipvlan.** Explain the core difference: macvlan gives each endpoint its own MAC (looks like separate hosts on the wire); ipvlan shares the parent's MAC and separates by IP (L2 mode) or routes (L3/L3s mode). Recommend based on the environment — macvlan for bare metal with permissive switches; ipvlan where the switch/cloud limits MACs or filters unknown source MACs.
2. **Name the isolation trap.** By design, a macvlan/ipvlan child cannot talk to its own parent host over that interface. If host↔endpoint communication is required, provide the workaround (a dedicated macvlan shim interface on the host, or route via a separate path) instead of letting the user discover it in production.
3. **Choose the mode.** For macvlan: `bridge` (endpoints talk to each other, the common choice), `vepa`, `private`, `passthru` — pick and justify. For ipvlan: `l2` vs `l3`/`l3s` and what each means for broadcast/ARP, DHCP, and routing.
4. **Handle cloud and switch constraints.** Flag that many clouds drop frames whose source MAC isn't the instance's assigned MAC — macvlan usually fails there, so recommend ipvlan L2/L3 or a routed/overlay approach. On bare metal, warn about switch port-security MAC limits and how many endpoints the port allows.
5. **Get DHCP and promiscuity right.** Note that macvlan+DHCP needs unique client identifiers (multiple endpoints share a link but need distinct leases), and when promiscuous mode on the parent is or isn't required.
6. **Give a concrete config.** Produce the `ip link add ... type macvlan/ipvlan` commands (or the container network / systemd-networkd equivalent), including VLAN tagging on the parent if needed, plus a verification and teardown sequence.

Output as: a macvlan-vs-ipvlan recommendation with justification for THIS environment, the exact interface/mode config, the host-connectivity workaround if needed, and environment-specific caveats (cloud MAC filtering, switch port-security).

Default to caution: in cloud VPCs assume unknown-MAC frames are dropped and prefer ipvlan or a routed design unless MAC spoofing is explicitly permitted.

Run this prompt with AI

Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.

Why this prompt works

macvlan and ipvlan look interchangeable until a cloud VPC silently drops your frames or the host can’t reach its own containers. This prompt makes the environment decide, names the built-in host-isolation trap up front, and produces config that matches the switch or cloud you actually run on.

How to use it

  1. State the environment (bare metal vs specific cloud) — it flips the recommendation.
  2. Say explicitly whether the host must reach the endpoints.
  3. Validate on a single endpoint before scaling, especially in a VPC.

Useful commands

# macvlan (bridge mode) child on a parent NIC
sudo ip link add mv0 link eth0 type macvlan mode bridge
sudo ip addr add 192.0.2.50/24 dev mv0 && sudo ip link set mv0 up

# ipvlan L2 child (shares parent MAC — cloud-friendly)
sudo ip link add ipv0 link eth0 type ipvlan mode l2
sudo ip addr add 192.0.2.51/24 dev ipv0 && sudo ip link set ipv0 up

# Host<->child shim so the host can reach macvlan endpoints
sudo ip link add mac-shim link eth0 type macvlan mode bridge
sudo ip addr add 192.0.2.2/32 dev mac-shim && sudo ip link set mac-shim up

# Verify and inspect
ip -d link show mv0
bridge fdb show dev mv0

Related prompts

More Linux Admins prompts & error guides

Browse every Linux Admins prompt and troubleshooting guide in one place.

Free download · 368-page PDF

Reading prompts? Get all 500 in one free PDF

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.