|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * virt/vm_networking/virt-connecting-vm-to-linux-bridge.adoc |
| 4 | + |
| 5 | +:_mod-docs-content-type: PROCEDURE |
| 6 | +[id="virt-linux-bridge-nad-port-isolation.adoc_{context}"] |
| 7 | += Enabling port isolation for a Linux bridge NAD |
| 8 | + |
| 9 | +You can enable port isolation for a Linux bridge network attachment definition (NAD) so that virtual machines (VMs) or pods that run on the same virtual LAN (VLAN) can operate in isolation from one another. The Linux bridge NAD creates a virtual bridge, or _virtual switch_, between network interfaces and the physical network. |
| 10 | + |
| 11 | +Isolating ports in this way can provide enhanced security for VM workloads that run on the same node. |
| 12 | + |
| 13 | +.Prerequisites |
| 14 | + |
| 15 | +* For VMs, you configured either a static or dynamic IP address for each VM. See "Configuring IP addresses for virtual machines". |
| 16 | +* You created a Linux bridge NAD by using either the web console or the command-line interface. |
| 17 | +
|
| 18 | +.Procedure |
| 19 | + |
| 20 | +. Edit the Linux bridge NAD by setting `portIsolation` to `true`: |
| 21 | ++ |
| 22 | +[source,yaml] |
| 23 | +---- |
| 24 | +apiVersion: "k8s.cni.cncf.io/v1" |
| 25 | +kind: NetworkAttachmentDefinition |
| 26 | +metadata: |
| 27 | + name: bridge-network |
| 28 | + annotations: |
| 29 | + k8s.v1.cni.cncf.io/resourceName: bridge.network.kubevirt.io/br1 |
| 30 | +spec: |
| 31 | + config: | |
| 32 | + { |
| 33 | + "cniVersion": "0.3.1", |
| 34 | + "name": "bridge-network", <1> |
| 35 | + "type": "bridge", <2> |
| 36 | + "bridge": "br1", <3> |
| 37 | + "preserveDefaultVlan": false, |
| 38 | + "vlan": 100, |
| 39 | + "disableContainerInterface": false, |
| 40 | + "portIsolation": true <4> |
| 41 | + } |
| 42 | +# ... |
| 43 | +---- |
| 44 | +<1> The name for the configuration. The name must match the the value in the `metadata.name` of the NAD. |
| 45 | +<2> The actual name of the Container Network Interface (CNI) plugin that provides the network for this network attachment definition. Do not change this field unless you want to use a different CNI. |
| 46 | +<3> The name of the Linux bridge that is configured on the node. The name must match the interface bridge name defined in the NodeNetworkConfigurationPolicy manifest. |
| 47 | +<4> Enables or disables port isolation on the virtual bridge. Default value is `false`. When set to `true`, each VM or pod is assigned to an isolated port. The virtual bridge prevents traffic from one isolated port from reaching another isolated port. |
| 48 | + |
| 49 | +. Apply the configuration: |
| 50 | ++ |
| 51 | +[source,terminal] |
| 52 | +---- |
| 53 | +$ oc apply -f example-vm.yaml |
| 54 | +---- |
| 55 | + |
| 56 | +. Optional: If you edited a running virtual machine, you must restart it for the changes to take effect. |
0 commit comments