|
| 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) that run on the same virtual LAN (VLAN) can operate in isolation from one another. When you assign an IP address to the virtual bridge, the virtual bridge can act as a gateway. The Linux bridge NAD creates a virtual bridge, or _virtual switch_, between network interfaces and the physical network. The Linux bridge NAD configures port numbers on the virtual bridge so that only specific traffic can reach each port. |
| 10 | + |
| 11 | + |
| 12 | +Isolating ports in this way can provide enhanced security, efficient resource use, and performance improvements for VM workloads that run on the same node. |
| 13 | + |
| 14 | +Before you enable port isolation, you must disable hairpin traffic from reaching the isolated ports. |
| 15 | + |
| 16 | +.Prerequisites |
| 17 | + |
| 18 | +* You created Linux bridge NAD by using either the web console or the command-line interface. |
| 19 | +
|
| 20 | +.Procedure |
| 21 | + |
| 22 | +. Edit the Linux bridge NAD by setting `portIsolation` to `true`: |
| 23 | ++ |
| 24 | +[source,yaml] |
| 25 | +---- |
| 26 | +apiVersion: "k8s.cni.cncf.io/v1" |
| 27 | +kind: NetworkAttachmentDefinition |
| 28 | +metadata: |
| 29 | + name: bridge-network |
| 30 | + annotations: |
| 31 | + k8s.v1.cni.cncf.io/resourceName: bridge.network.kubevirt.io/br1 |
| 32 | +spec: |
| 33 | + config: | |
| 34 | + { |
| 35 | + "cniVersion": "0.3.1", |
| 36 | + "name": "bridge-network", <1> |
| 37 | + "type": "bridge", <2> |
| 38 | + "bridge": "br1", <3> |
| 39 | + "hairpinMode": "true", <4> |
| 40 | + "portIsolation": "true" <5> |
| 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 should match the interface bridge name defined in the NodeNetworkConfigurationPolicy manifest. |
| 47 | +<4> Defaults to `false`. When set to `true`, network interfaces that interact with the virtual bridges |
| 48 | +<5> Enables or disables port isolation on the virtual bridge. Default value is `false`. When set to `true`, each targeted VM is assigned to a specific port number. The virtual bridge prevents traffic from one isolated port from reaching another isolated port. |
| 49 | + |
| 50 | +. Apply the configuration: |
| 51 | ++ |
| 52 | +[source,terminal] |
| 53 | +---- |
| 54 | +$ oc apply -f example-vm.yaml |
| 55 | +---- |
| 56 | + |
| 57 | +. Optional: If you edited a running virtual machine, you must restart it for the changes to take effect. |
0 commit comments