Technical Insight Explanation

KubeVirt Networking Explained: Pod Networks, Bridges and Masquerade

Understand KubeVirt bridge and masquerade bindings, guest IP addressing, NAT, Services and NetworkPolicy in a hands-on connectivity lab.

KubeVirt Networking Explained: Pod Networks, Bridges and Masquerade
On this page

A KubeVirt guest can have a working IP address while every other pod in the cluster is unable to route to that address. With masquerade binding, that is an expected consequence of the design. The guest lives behind a translation boundary inside the launcher pod. The cluster reaches the pod-facing endpoint; the guest uses a separate address on the inside.

That distinction explains why a VM can reach DNS but reject an inbound connection, why a Kubernetes Service can work without targeting the guest’s private IP, and why changing an interface binding can affect more than connectivity. The operational question is which address exists at each boundary, and which component owns the next hop?

This guide explains how primary pod-network bindings work in KubeVirt and includes a self-contained connectivity lab (targeting KubeVirt v1.6.0) to inspect the interfaces, routes, NAT boundaries, and NetworkPolicy behavior directly in a cluster. It builds on running and managing VMs on Kubernetes without repeating the introduction. Secondary networks, SR-IOV, and external load-balancer design require separate treatment.

KubeVirt network and interface resources

Two parts of a VirtualMachineInstance (VMI) definition cooperate. spec.networks selects a network source, while spec.domain.devices.interfaces selects how a guest NIC attaches to that source. Matching name fields join the two. In a persistent VirtualMachine, these fields sit beneath spec.template.spec:

spec:
  template:
    spec:
      domain:
        devices:
          interfaces:
            - name: default
              masquerade: {}
      networks:
        - name: default
          pod: {}

pod: {} selects the pod network supplied by the cluster’s primary CNI. masquerade: {} selects the binding between that network and the guest. The word default is the shared name in this example; it does not select an implementation by itself.

Kubernetes and its CNI prepare the launcher pod’s network attachment. KubeVirt prepares the guest-facing connection and virtual NIC. The guest then configures its own network stack. A VMI reaching Running does not prove that DHCP completed, DNS works, or an application is listening.

Keep the API layers separate when troubleshooting: a rejected VM definition is an admission problem; a pod without a usable network is a CNI problem; a guest without a lease is further inward. Controllers reconcile these resources, but guest packets do not travel through virt-controller or virt-api.

Pod network and masquerade binding

Masquerade gives the guest an address on an internal subnet (by default 10.0.2.0/24, with the gateway at 10.0.2.1 and the guest at 10.0.2.2, configurable via vmNetworkCIDR) and translates traffic between that subnet and the pod-facing network. A TAP connects the virtual NIC to a Linux bridge inside the launcher network namespace, and NAT provides the transition to the CNI attachment. An internal Linux bridge exists in this model even though the selected KubeVirt binding is called masquerade. Seeing a bridge device inside the launcher namespace does not establish that a VMI uses bridge: {}.

Conceptual outbound and Service inbound flows through the launcher network namespace, with the guest-private and cluster address spaces separated

Treat device names and implementation choices as observations to collect from the selected release. Do not build a diagnostic around an assumed bridge name or a particular iptables/nftables backend. Inspect the actual interfaces, routes, and available rule representation before interpreting a packet capture.

For a guest-initiated connection, the guest sends traffic toward its internal gateway. KubeVirt’s masquerade path translates the guest source to the pod-facing address; the CNI and cluster routing then carry it onward. Node or perimeter NAT may add another translation for external destinations, meaning the destination need not observe either the guest-private address or the original pod address.

Return traffic follows connection state back toward the guest. An established outbound connection does not prove that a new inbound connection will work. New inbound traffic must reach the correct pod-facing port, survive policy and forwarding, and find a guest process listening on the destination port.

The extra address boundary is useful when a guest should behave like a standard workload behind Kubernetes networking. It is a poor fit if the guest must own an externally assigned Layer 2 identity directly. Make that requirement explicit before selecting the binding.

Bridge binding scope and compatibility

Comparison of masquerade and primary pod-network bridge binding

Bridge binding connects the guest to a network using a different model from masquerade. On the primary pod network, the documented design delegates the pod-network address to the guest through DHCP rather than placing it behind the masquerade subnet. This changes the relationship between the launcher pod’s reported address and the addresses configured inside its namespace.

It is tempting to interpret bridge binding as “remove NAT and everything becomes simpler.” That overlooks the primary CNI’s assumptions about addresses, MAC addresses, and interface ownership. Some CNI implementations impose restrictions that conflict with bridge delegation. Support must be established for your exact KubeVirt release and CNI configuration; a successful experiment on another CNI is insufficient evidence.

Bridge binding on the primary pod network introduces live-migration restrictions because the guest network identity is coupled to the pod-network attachment. Any exception must be validated against the exact KubeVirt release and CNI implementation. Masquerade is the standard primary-network candidate when evaluating live migration—though choosing it does not automatically make the whole VM migratable, as storage, devices, and cluster configuration introduce independent constraints.

RequirementMasquerade candidateBridge candidateEvidence needed before selection
Kubernetes Service in front of a guest applicationPod-facing port forwarded to guestRequires compatible pod-network attachmentEndpoint, guest listener and policy tests
Guest keeps a separate internal IPFits the address modelDifferent address-delegation modelGuest route and lease inspection
Primary-network live migrationEvaluate with remaining VM constraintsDocumented restriction; do not assume supportRelease-specific migration support review
Direct external Layer 2 identityDoes not supply it through NATNot guaranteed by the binding nameCNI and physical-network design review
Uniform policy across CNIsMust be testedMust be tested, plus binding compatibilityActual allow/deny observations

The table above is a selection framework rather than a compatibility certification.

Where passt fits

Passt provides a userspace networking alternative. Its integration, address handling and migration support depend on the KubeVirt release and binding implementation. Do not assume it is NAT-free or that newer native passtBinding examples apply to v1.6.0. This lab deliberately uses masquerade only.

DHCP, addressing, and Service connectivity

For masquerade, KubeVirt supplies guest-facing DHCP configuration for the internal network. The guest must have a functioning DHCP client and compatible interface configuration. A static configuration copied from a different hypervisor can leave a healthy NIC with no useful default route.

Compare three observations: the launcher pod’s Kubernetes IP, the VMI’s reported interface data, and the address and routes inside the guest. They answer different questions. Guest-agent information can improve visibility, but absent guest-agent data does not prove that the guest has no network.

A Kubernetes Service selects the launcher pod using labels propagated from the VM template. Its EndpointSlice identifies the selected pod-facing address. For masquerade, that is the outside of the translation boundary. Manually putting the guest-private address into a Service endpoint bypasses the intended model and does not make that subnet routable.

In the lab below, a Service maps TCP port 80 to guest TCP port 8080. port is the client-facing Service port; targetPort is the destination port reached through the launcher endpoint. Guest software must listen on its guest interface or a wildcard address (0.0.0.0 / ::); a listener bound only to guest loopback (127.0.0.1) cannot receive forwarded traffic.

KubeVirt’s interfaces[].ports field can constrain which ports masquerade forwards into the guest. When ports is omitted, masquerade generally forwards incoming ports to the guest, subject to reserved ports and other implementation constraints. An explicit list restricts forwarding to the declared ports and protocols. Keep in mind two operational details:

  • TCP ports 49152 and 49153 are reserved by KubeVirt for live migration; explicitly listing them in ports will block live migration.
  • interfaces[].ports is not a replacement for NetworkPolicy or a guest firewall. Those controls operate at different boundaries and can each reject traffic independently.

DNS is another multi-stage dependency. Inspect the guest’s /etc/resolv.conf as well as the launcher pod’s resolver configuration. A working IP connection with a failing name points toward DNS; a successful lookup with a failed TCP connection points elsewhere.

Inbound, outbound, and east-west packet flows

When validating traffic paths, start with an outbound connection from the guest to a same-namespace test server (probe-http in the lab). Record the guest route, the pod-facing route, and what source address the server observes. A cluster-internal destination isolates the experiment from internet egress and perimeter NAT.

For inbound traffic, start at the Service and work inward: Service definition, EndpointSlice, policy decision, pod-facing destination port, NAT forwarding, guest NIC, and listener. Kubernetes may implement Service forwarding with different dataplanes (iptables, ipvs, or eBPF).

East-west VM traffic with masquerade crosses both workloads’ network boundaries. A guest on VM A does not address VM B through B’s private masquerade address (10.0.2.2). Instead, it uses B’s reachable pod-facing endpoint or a Kubernetes Service. B’s inbound translation then delivers the connection to its guest.

NetworkPolicy selects the launcher pod, not a separate Kubernetes object representing each guest process. Guest-private addresses are not a portable identity for cluster policy. In particular, an ipBlock rule around a Service can have implementation-dependent consequences because address translation and policy enforcement interact.

Hands-on connectivity lab

This lab deploys an ephemeral CirrOS VM (net-demo) using masquerade binding alongside a lightweight probe pod in an isolated kv05-net-lab namespace. It verifies bidirectional HTTP connectivity, inspects the launcher pod’s network namespace, tests NetworkPolicy ingress isolation, and cleans up all resources.

Prerequisites

  • A non-production Linux x86_64 Kubernetes cluster with usable KVM, KubeVirt (v1.6.0 baseline), and a matching virtctl CLI.
  • A CNI plugin that enforces NetworkPolicy.
  • RBAC permissions to create namespaces, VirtualMachine resources, Pods, Services, and NetworkPolicy objects, plus console and exec access.

The target baseline is KubeVirt v1.6.0 on Linux x86_64 with KVM and CirrOS. Record the actual Kubernetes distribution, Kubernetes version, CNI and CNI version before interpreting results. The outputs below are expected or illustrative, not recorded test results.

Verify your cluster context and KubeVirt installation before creating any resources:

kubectl config current-context
kubectl get nodes -o wide
kubectl get kubevirt -A -o wide
virtctl version

Deploy the baseline manifests

Save the following manifest as baseline.yaml. Note how VirtualMachine template labels (lab: kv05, role: guest) propagate to the virt-launcher pod so the guest-http Service can select it, while interfaces[].ports explicitly declares TCP port 8080:

apiVersion: kubevirt.io/v1
kind: VirtualMachine
metadata:
  name: net-demo
  namespace: kv05-net-lab
spec:
  runStrategy: Manual
  template:
    metadata:
      labels:
        lab: kv05
        role: guest
    spec:
      terminationGracePeriodSeconds: 30
      domain:
        cpu:
          cores: 1
        resources:
          requests:
            memory: 256Mi
        devices:
          disks:
            - name: rootdisk
              disk:
                bus: virtio
          interfaces:
            - name: default
              masquerade: {}
              ports:
                - name: http
                  port: 8080
                  protocol: TCP
      networks:
        - name: default
          pod: {}
      volumes:
        - name: rootdisk
          containerDisk:
            image: quay.io/kubevirt/cirros-container-disk-demo@sha256:b3173a795eddc0c8f6923bb197928b7c0876aade4daf85d0558dfae65f403fe2
---
apiVersion: v1
kind: Service
metadata:
  name: guest-http
  namespace: kv05-net-lab
spec:
  selector:
    lab: kv05
    role: guest
  ports:
    - name: http
      port: 80
      targetPort: 8080
      protocol: TCP
---
apiVersion: v1
kind: Pod
metadata:
  name: probe
  namespace: kv05-net-lab
  labels:
    lab: kv05
    role: probe
spec:
  automountServiceAccountToken: false
  securityContext:
    runAsNonRoot: true
    runAsUser: 10000
    runAsGroup: 10000
    seccompProfile:
      type: RuntimeDefault
  containers:
    - name: probe
      # Resolve and pin the image digest in production or shared environments
      image: busybox:1.37.0
      command: ["sh", "-ec"]
      args:
        - 'mkdir -p /tmp/www; printf "probe-response\n" > /tmp/www/index.html; exec httpd -f -p 8080 -h /tmp/www'
      securityContext:
        allowPrivilegeEscalation: false
        readOnlyRootFilesystem: true
        capabilities:
          drop: ["ALL"]
      resources:
        requests:
          cpu: 10m
          memory: 16Mi
        limits:
          cpu: 100m
          memory: 64Mi
      volumeMounts:
        - name: scratch
          mountPath: /tmp
  volumes:
    - name: scratch
      emptyDir:
        sizeLimit: 16Mi
---
apiVersion: v1
kind: Service
metadata:
  name: probe-http
  namespace: kv05-net-lab
spec:
  selector:
    lab: kv05
    role: probe
  ports:
    - name: http
      port: 8080
      targetPort: 8080

Create the isolated namespace, apply the manifests, start the VM, and wait for both workloads to become ready:

kubectl create namespace kv05-net-lab
kubectl apply --dry-run=server -f baseline.yaml
kubectl apply -f baseline.yaml
virtctl -n kv05-net-lab start net-demo
kubectl -n kv05-net-lab wait --for=create vmi/net-demo --timeout=120s
kubectl -n kv05-net-lab wait --for=jsonpath='{.status.phase}'=Running vmi/net-demo --timeout=300s
kubectl -n kv05-net-lab wait --for=condition=Ready pod/probe --timeout=180s

Verify that the guest-http Service EndpointSlice points to the virt-launcher pod IP and confirm owner UID matching:

kubectl -n kv05-net-lab get vm,vmi,pods,services -o wide
kubectl -n kv05-net-lab get endpointslice -l kubernetes.io/service-name=guest-http -o yaml
kubectl -n kv05-net-lab get vmi net-demo -o jsonpath='{.metadata.uid}{"\n"}'
kubectl -n kv05-net-lab get pods -l lab=kv05,role=guest \
  -o custom-columns='NAME:.metadata.name,OWNER:.metadata.ownerReferences[0].uid,IP:.status.podIP,NODE:.spec.nodeName'

Start the HTTP listener inside the guest

Connect to the serial console of net-demo (default CirrOS demo credentials are cirros / gocubsgo):

virtctl -n kv05-net-lab console net-demo

Inside the guest console, inspect the guest’s internal IPv4 address, default route, and resolver configuration, then start a lightweight HTTP server on port 8080:

ip -4 address
ip route
cat /etc/resolv.conf
mkdir -p /tmp/kv05-www
printf 'guest-response\n' > /tmp/kv05-www/index.html
busybox httpd -p 8080 -h /tmp/kv05-www

You should see an internal guest IP (such as 10.0.2.2/24) rather than the launcher pod’s CNI IP.

Test inbound and outbound Service traffic

While still inside the guest console, test outbound connectivity and cluster DNS resolution against the probe-http Service:

busybox wget -T 5 -O- http://probe-http:8080/

Expected output: probe-response. (If the short Service name fails, test the probe-http ClusterIP directly to separate DNS resolution issues from TCP routing.) Exit the guest console with Ctrl+].

Next, from your host terminal, send an inbound request from the probe pod to the guest-http Service:

kubectl -n kv05-net-lab exec probe -- wget -T 5 -qO- http://guest-http/

Expected output: guest-response. Even though the guest is only listening on its private masquerade subnet, the Service forwards port 80 to the launcher pod’s targetPort 8080, where KubeVirt’s NAT rules translate the packet to the guest.

To separate Service forwarding from masquerade forwarding, test the launcher endpoint directly:

LAUNCHER_IP=$(kubectl -n kv05-net-lab get pods -l lab=kv05,role=guest -o jsonpath='{.items[0].status.podIP}')
kubectl -n kv05-net-lab exec probe -- wget -T 5 -qO- "http://${LAUNCHER_IP}:8080/"

Expected output: guest-response.

Inspect the launcher network namespace

Set LAUNCHER_POD to your virt-launcher-net-demo-* pod name and inspect the links, addresses, and routes inside the compute container:

LAUNCHER_POD=$(kubectl -n kv05-net-lab get pods -l lab=kv05,role=guest -o jsonpath='{.items[0].metadata.name}')
kubectl -n kv05-net-lab exec "$LAUNCHER_POD" -c compute -- ip -d link
kubectl -n kv05-net-lab exec "$LAUNCHER_POD" -c compute -- ip -4 address
kubectl -n kv05-net-lab exec "$LAUNCHER_POD" -c compute -- ip route

Observe the three distinct components inside the launcher namespace: the CNI pod interface (eth0), the internal Linux bridge (typically k6t-eth0), and the tap0 device connected to the QEMU process. Compare their MTU values to verify whether the bridge and TAP inherit the CNI pod MTU.

(Note: If you have authorized node-level or ephemeral-container diagnostic access with tcpdump, running tcpdump -ni <interface> -s 96 -c 20 'tcp port 8080' simultaneously on eth0 and tap0 while curling guest-http will show the destination IP rewrite from the launcher pod IP on eth0 to the guest’s 10.0.2.2 address on tap0.)

If the diagnostic binary and permissions are available, inspect NAT rules:

kubectl -n kv05-net-lab exec "$LAUNCHER_POD" -c compute -- nft list ruleset

If unavailable, use authorized node-level diagnostics in the launcher network namespace, inspecting the actual nftables or iptables backend. Do not grant extra workload privileges merely to run this experiment.

For an illustrative inbound trace (not measured output), a probe at 10.244.1.20 sends traffic to Service 10.96.20.80:80. The Service dataplane selects launcher 10.244.1.15:8080; KubeVirt then translates the destination to 10.0.2.2:8080. The source may change depending on the dataplane. Capture traffic at the pod and TAP interfaces to verify this. For outbound traffic, an authorized capture at the probe endpoint on TCP 8080 can reveal the source address observed by the receiving workload.

Validate NetworkPolicy isolation and recovery

Save the following ingress-deny policy as deny-guest-ingress.yaml. Notice that podSelector targets the launcher pod’s labels (lab: kv05, role: guest):

apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: deny-guest-ingress
  namespace: kv05-net-lab
spec:
  podSelector:
    matchLabels:
      lab: kv05
      role: guest
  policyTypes:
    - Ingress
  ingress: []

Apply the policy and test a new connection from probe (egress remains unrestricted so DNS does not interfere with the inbound test):

kubectl apply -f deny-guest-ingress.yaml
kubectl -n kv05-net-lab exec probe -- wget -T 5 -qO- http://guest-http/

Once your CNI converges, new connections to guest-http should time out or be rejected, provided no other applicable NetworkPolicy permits ingress. NetworkPolicies are additive. Delete the policy to confirm recovery:

kubectl -n kv05-net-lab delete networkpolicy deny-guest-ingress
kubectl -n kv05-net-lab exec probe -- wget -T 5 -qO- http://guest-http/

Once the CNI has reconciled policy removal, new connections should return guest-response again.

Clean up lab resources

Stop the VM cleanly before deleting the lab resources and namespace:

virtctl -n kv05-net-lab stop net-demo
kubectl -n kv05-net-lab wait --for=delete vmi/net-demo --timeout=180s
kubectl -n kv05-net-lab delete vm net-demo
kubectl -n kv05-net-lab delete -f deny-guest-ingress.yaml --ignore-not-found
kubectl -n kv05-net-lab delete pod probe
kubectl -n kv05-net-lab delete service guest-http probe-http
kubectl delete namespace kv05-net-lab

Debugging MTU, DNS, and connectivity

When troubleshooting production KubeVirt workloads, work from a known destination and record each boundary. A random collection of successful pings is weak evidence for an application path: ICMP, UDP DNS, and TCP applications exercise different behavior.

SymptomNext observationWhat it helps distinguish
Guest has no IPv4 addressGuest NIC state, DHCP client and console logsGuest configuration versus pod networking
Service has no endpointTemplate labels and EndpointSliceSelection versus forwarding
Direct endpoint works; Service failsService port/targetPort and dataplane stateService path versus guest listener
Name fails; known destination IP worksGuest resolver, DNS responses, UDP/TCP 53 policyDNS versus application routing
Small requests work; larger transfers stallGuest/pod MTU, path MTU feedback, packet sizesEncapsulation or MTU mismatch
Deny policy changes nothingSelected pod labels, new flows, CNI enforcementPolicy selection/support versus assumptions

MTU debugging requires measurements from the actual environment. Overlay encapsulation (such as VXLAN or Geneve) reduces the effective path MTU; blocked path-MTU feedback can turn that into stalled TCP transfers. Compare guest and pod MTU settings and test progressively larger payloads, keeping in mind that a failed large ping alone can be inconclusive if ICMP is filtered.

Operational boundaries worth preserving

The lab above uses an ephemeral containerDisk and an in-memory HTTP listener. It is strictly disposable: changes to the ephemeral writable disk layer are lost when the VMI is destroyed and recreated, and the demo image is not hardened for production workloads.

Similarly, a working internal ClusterIP Service does not justify exposing a VM directly through a public LoadBalancer without accounting for source-address preservation (externalTrafficPolicy), authentication, TLS termination, and perimeter firewall rules. Before adopting a primary-network binding in production, document the required address identity, live-migration behavior, and NetworkPolicy boundary, then validate those assumptions against your exact CNI version. If an application requires a direct Layer 2 identity, design a secondary Multus network rather than forcing exceptions onto the primary pod-network NAT path.

Kubernetes networking does not stop at the virtual machine

KubeVirt introduces another networking boundary inside an existing Kubernetes workload. With masquerade, the guest owns a private IP address, Kubernetes owns the reachable workload endpoint, and KubeVirt connects the two through translation. With bridge binding, that separation changes. So do the assumptions about network identity, CNI compatibility and mobility.

The architectural decision is not simply whether to enable NAT or create a bridge. It is deciding which component should own the network identity of the virtual machine. That decision determines how the VM participates in service discovery, network security and live migration. When the primary pod network cannot satisfy those requirements, the answer is not another NAT rule. It is a different network attachment architecture.

Upstream references

Related Articles

Stay ahead

Get the latest insights.

Insights on cloud, AI and open source — delivered to your inbox.

Email subscriptions are coming soon.