---
title: "Allocating an IP Address"
canonical: "https://docs.infoblox.com/space/ipamdriverterraform/53154167/Allocating%20an%20IP%20Address"
format: markdown
---
You can allocate an IP address from a network and for a virtual machine in the NIOS appliance. To create an IP address for a network, NIOS sends a request from the network block to the next IP address available.

The `infoblox_ip_association` and `infoblox_ip_allocation` resources block together form the IP address allocation. The `infoblox_ip_association` resource block is also used to update the virtual machine properties such as `mac_addr` and `vm_id`.

Using the `infoblox_ip_allocation` resource block, an IP address is reserved in NIOS appliance. For example, if the `ip_addr` parameter is not set then the  `infoblox_ip_allocation` resource block reserves the next available IP address from the network. However, to set the fixed IP address you need to specify the `ip_addr` parameter.

If you specify the `dns_view` and `zone` parameters, NIOS creates a host record or it creates a fixed IP address. If you want to use the host record for DNS or DHCP purposes, you need to set the value of `enable_dns` parameter to `true`.` `

The following table describes the mandatory and optional parameters used to allocate and associate an IP address.

| **Sr No** | **Parameter** | **Mandatory/**  
**Optional** | **Description** |
| --- | --- | --- | --- |
| 1 | network_view_name | Optional | Specifies the network view name available in the NIOS appliance. |
| 2 | vm_name | Mandatory | Specifies the name of the virtual machine. |
| 3 | cidr | Mandatory | Specifies the address in `cidr` format.<br>> ⚠️ **Note**
> ⚠️ 
> ⚠️ Ensure the network address is available in NIOS, under the required network view (`network_view_name`). |
| 4 | zone | Optional | Specifies the zone under which the record has to be created. |
| 5 | enable_dns | Optional | Specifies the flag that defines whether the host record is used for DNS or IPAM purposes. |
| 6 | dns_view | Optional | Specifies the DNS view under which the zone is created. |
| 7 | ip_addr | Optional | Specifies the IP address of the instance in the cloud.<br>For static allocation, you need to set the field with a valid IP address. |
| 8 | mac_addr | Optional | Specifies the MAC address of the instance in the cloud. |
| 9 | vm_id | Optional | Specifies the instance ID. |
| 10 | tenant_id | Mandatory | Specifies the unique identifier of the tenant in the cloud.<br>Tenant ID is the name of the cloud provider with which you want to integrate. However, if there is no cloud provider, you can specify any dummy value.<br>The tenant ID differentiates the cloud providers in NIOS. For more information, see <u>*[Viewing All Tenants](https://infoblox-docs.atlassian.net/wiki/spaces/nios85/pages/35386136)*</u>. |

> ⚠️ **Note**
> ⚠️ 
> ⚠️ To create a host record, you need to set the `enable_dns` and `dns_view` parameters for `infoblox_ip_allocation` and `infoblox_ip_association` resource blocks.

## Example

The following examples form the IP address allocation:

`resource "infoblox_ip_allocation" "demo_allocation"`

`{`

`network_view_name="demo1"`

`vm_name="vmname1"`

`cidr=10.0.0.0./24`

`tenant_id="test"`

`}`


`resource "infoblox_ip_association" "demo_associate"`

`{`  
`network_view_name="demo1"`  
`vm_name="vmname1"`  
`cidr=10.0.0.0./24`  
`mac_addr =11:11:11:11:11:11:11`  
`ip_addr="10.0.0.2"`  
`vm_id =testtenant_id="test"`

`}`