Skip to content

Commit e015295

Browse files
Adding content for configuring IP addresses (statis or dynamic) for VMs
1 parent 0f8ddc9 commit e015295

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

_topic_map.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,6 +2569,8 @@ Topics:
25692569
File: virt-using-the-default-pod-network-with-virt
25702570
- Name: Attaching a virtual machine to multiple networks
25712571
File: virt-attaching-vm-multiple-networks
2572+
- Name: Configuring IP addresses for virtual machines
2573+
File: virt-configuring-ip-for-vms
25722574
- Name: Configuring an SR-IOV network device for virtual machines
25732575
File: virt-configuring-sriov-device-for-vms
25742576
- Name: Defining an SR-IOV network
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Module included in the following assemblies:
2+
//
3+
// * virt/virtual_machines/vm_networking/virt-configuring-ip-for-vms.adoc
4+
5+
[id="virt-configuring-ip-for-new-vm-cloud-init_{context}"]
6+
= Configuring an IP address for a new virtual machine using cloud-init
7+
8+
You can use cloud-init to configure an IP address when you create a virtual machine. The IP address can be dynamically or statically provisioned.
9+
10+
.Procedure
11+
12+
* Create a virtual machine configuration and include the cloud-init network details in the `spec.volumes.cloudInitNoCloud.networkData` field of the virtual machine configuration:
13+
14+
.. To configure a dynamic IP, specify the interface name and the `dhcp4` boolean:
15+
+
16+
[source,yaml]
17+
----
18+
kind: VirtualMachine
19+
spec:
20+
...
21+
volumes:
22+
- cloudInitNoCloud:
23+
networkData: |
24+
version: 2
25+
ethernets:
26+
eth1: <1>
27+
dhcp4: true <2>
28+
----
29+
<1> The interface name.
30+
<2> Uses DHCP to provision an IPv4 address.
31+
32+
.. To configure a static IP, specify the interface name and the IP address:
33+
+
34+
[source,yaml]
35+
----
36+
kind: VirtualMachine
37+
spec:
38+
...
39+
volumes:
40+
- cloudInitNoCloud:
41+
networkData: |
42+
version: 2
43+
ethernets:
44+
eth1: <1>
45+
addresses:
46+
- 10.10.10.14/24 <2>
47+
----
48+
<1> The interface name.
49+
<2> The static IP address for the virtual machine.

virt/virtual_machines/vm_networking/virt-attaching-vm-multiple-networks.adoc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ in the previous section.
4545
include::modules/virt-vm-create-nic-web.adoc[leveloffset=+1]
4646

4747
include::modules/virt-networking-wizard-fields-web.adoc[leveloffset=+1]
48+
49+
[id="{context}_additional-resources"]
50+
== Additional resources
51+
52+
* xref:../../../virt/virtual_machines/vm_networking/virt-configuring-ip-for-vms.adoc#virt-configuring-ip-for-vms[Configuring IP addresses for virtual machines]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[id="virt-configuring-ip-for-vms"]
2+
= Configuring IP addresses for virtual machines
3+
include::modules/virt-document-attributes.adoc[]
4+
:context: virt-configuring-ip-for-vms
5+
toc::[]
6+
7+
You can configure either dynamically or statically provisioned IP addresses for virtual machines.
8+
9+
.Prerequisites
10+
11+
* The virtual machine can connect to a xref:../../../virt/virtual_machines/vm_networking/virt-attaching-vm-multiple-networks.adoc#attaching-to-multiple-networks[secondary network]
12+
13+
* To configure a dynamic IP for the virtual machine, you must have a DHCP server available on the secondary network.
14+
15+
include::modules/virt-configuring-ip-for-new-vm-cloud-init.adoc[leveloffset=+1]
16+

0 commit comments

Comments
 (0)