1. Packages
  2. Openwrt Provider
  3. API Docs
  4. DhcpHost
openwrt 0.0.20 published on Friday, Mar 7, 2025 by joneshf

openwrt.DhcpHost

Explore with Pulumi AI

Assign a fixed IP address to hosts.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as openwrt from "@pulumi/openwrt";

const testing = new openwrt.DhcpHost("testing", {
    dhcpHostId: "testing",
    ip: "192.168.1.50",
    mac: "12:34:56:78:90:ab",
});
Copy
import pulumi
import pulumi_openwrt as openwrt

testing = openwrt.DhcpHost("testing",
    dhcp_host_id="testing",
    ip="192.168.1.50",
    mac="12:34:56:78:90:ab")
Copy
package main

import (
	"github.com/pulumi/pulumi-terraform-provider/sdks/go/openwrt/openwrt"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := openwrt.NewDhcpHost(ctx, "testing", &openwrt.DhcpHostArgs{
			DhcpHostId: pulumi.String("testing"),
			Ip:         pulumi.String("192.168.1.50"),
			Mac:        pulumi.String("12:34:56:78:90:ab"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Openwrt = Pulumi.Openwrt;

return await Deployment.RunAsync(() => 
{
    var testing = new Openwrt.DhcpHost("testing", new()
    {
        DhcpHostId = "testing",
        Ip = "192.168.1.50",
        Mac = "12:34:56:78:90:ab",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.openwrt.DhcpHost;
import com.pulumi.openwrt.DhcpHostArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var testing = new DhcpHost("testing", DhcpHostArgs.builder()
            .dhcpHostId("testing")
            .ip("192.168.1.50")
            .mac("12:34:56:78:90:ab")
            .build());

    }
}
Copy
resources:
  testing:
    type: openwrt:DhcpHost
    properties:
      dhcpHostId: testing
      ip: 192.168.1.50
      mac: 12:34:56:78:90:ab
Copy

Create DhcpHost Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new DhcpHost(name: string, args: DhcpHostArgs, opts?: CustomResourceOptions);
@overload
def DhcpHost(resource_name: str,
             args: DhcpHostArgs,
             opts: Optional[ResourceOptions] = None)

@overload
def DhcpHost(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             dhcp_host_id: Optional[str] = None,
             dns: Optional[bool] = None,
             ip: Optional[str] = None,
             mac: Optional[str] = None,
             name: Optional[str] = None)
func NewDhcpHost(ctx *Context, name string, args DhcpHostArgs, opts ...ResourceOption) (*DhcpHost, error)
public DhcpHost(string name, DhcpHostArgs args, CustomResourceOptions? opts = null)
public DhcpHost(String name, DhcpHostArgs args)
public DhcpHost(String name, DhcpHostArgs args, CustomResourceOptions options)
type: openwrt:DhcpHost
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. DhcpHostArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. DhcpHostArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. DhcpHostArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. DhcpHostArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. DhcpHostArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var dhcpHostResource = new Openwrt.DhcpHost("dhcpHostResource", new()
{
    DhcpHostId = "string",
    Dns = false,
    Ip = "string",
    Mac = "string",
    Name = "string",
});
Copy
example, err := openwrt.NewDhcpHost(ctx, "dhcpHostResource", &openwrt.DhcpHostArgs{
	DhcpHostId: pulumi.String("string"),
	Dns:        pulumi.Bool(false),
	Ip:         pulumi.String("string"),
	Mac:        pulumi.String("string"),
	Name:       pulumi.String("string"),
})
Copy
var dhcpHostResource = new DhcpHost("dhcpHostResource", DhcpHostArgs.builder()
    .dhcpHostId("string")
    .dns(false)
    .ip("string")
    .mac("string")
    .name("string")
    .build());
Copy
dhcp_host_resource = openwrt.DhcpHost("dhcpHostResource",
    dhcp_host_id="string",
    dns=False,
    ip="string",
    mac="string",
    name="string")
Copy
const dhcpHostResource = new openwrt.DhcpHost("dhcpHostResource", {
    dhcpHostId: "string",
    dns: false,
    ip: "string",
    mac: "string",
    name: "string",
});
Copy
type: openwrt:DhcpHost
properties:
    dhcpHostId: string
    dns: false
    ip: string
    mac: string
    name: string
Copy

DhcpHost Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The DhcpHost resource accepts the following input properties:

DhcpHostId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
Dns bool
Add static forward and reverse DNS entries for this host.
Ip string
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
Mac string
The hardware address(es) of this host, separated by spaces.
Name string
Hostname to assign.
DhcpHostId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
Dns bool
Add static forward and reverse DNS entries for this host.
Ip string
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
Mac string
The hardware address(es) of this host, separated by spaces.
Name string
Hostname to assign.
dhcpHostId This property is required. String
Name of the section. This name is only used when interacting with UCI directly.
dns Boolean
Add static forward and reverse DNS entries for this host.
ip String
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
mac String
The hardware address(es) of this host, separated by spaces.
name String
Hostname to assign.
dhcpHostId This property is required. string
Name of the section. This name is only used when interacting with UCI directly.
dns boolean
Add static forward and reverse DNS entries for this host.
ip string
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
mac string
The hardware address(es) of this host, separated by spaces.
name string
Hostname to assign.
dhcp_host_id This property is required. str
Name of the section. This name is only used when interacting with UCI directly.
dns bool
Add static forward and reverse DNS entries for this host.
ip str
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
mac str
The hardware address(es) of this host, separated by spaces.
name str
Hostname to assign.
dhcpHostId This property is required. String
Name of the section. This name is only used when interacting with UCI directly.
dns Boolean
Add static forward and reverse DNS entries for this host.
ip String
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
mac String
The hardware address(es) of this host, separated by spaces.
name String
Hostname to assign.

Outputs

All input properties are implicitly available as output properties. Additionally, the DhcpHost resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing DhcpHost Resource

Get an existing DhcpHost resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: DhcpHostState, opts?: CustomResourceOptions): DhcpHost
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        dhcp_host_id: Optional[str] = None,
        dns: Optional[bool] = None,
        ip: Optional[str] = None,
        mac: Optional[str] = None,
        name: Optional[str] = None) -> DhcpHost
func GetDhcpHost(ctx *Context, name string, id IDInput, state *DhcpHostState, opts ...ResourceOption) (*DhcpHost, error)
public static DhcpHost Get(string name, Input<string> id, DhcpHostState? state, CustomResourceOptions? opts = null)
public static DhcpHost get(String name, Output<String> id, DhcpHostState state, CustomResourceOptions options)
resources:  _:    type: openwrt:DhcpHost    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
DhcpHostId string
Name of the section. This name is only used when interacting with UCI directly.
Dns bool
Add static forward and reverse DNS entries for this host.
Ip string
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
Mac string
The hardware address(es) of this host, separated by spaces.
Name string
Hostname to assign.
DhcpHostId string
Name of the section. This name is only used when interacting with UCI directly.
Dns bool
Add static forward and reverse DNS entries for this host.
Ip string
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
Mac string
The hardware address(es) of this host, separated by spaces.
Name string
Hostname to assign.
dhcpHostId String
Name of the section. This name is only used when interacting with UCI directly.
dns Boolean
Add static forward and reverse DNS entries for this host.
ip String
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
mac String
The hardware address(es) of this host, separated by spaces.
name String
Hostname to assign.
dhcpHostId string
Name of the section. This name is only used when interacting with UCI directly.
dns boolean
Add static forward and reverse DNS entries for this host.
ip string
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
mac string
The hardware address(es) of this host, separated by spaces.
name string
Hostname to assign.
dhcp_host_id str
Name of the section. This name is only used when interacting with UCI directly.
dns bool
Add static forward and reverse DNS entries for this host.
ip str
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
mac str
The hardware address(es) of this host, separated by spaces.
name str
Hostname to assign.
dhcpHostId String
Name of the section. This name is only used when interacting with UCI directly.
dns Boolean
Add static forward and reverse DNS entries for this host.
ip String
The IP address to be used for this host, or ignore to ignore any DHCP request from this host.
mac String
The hardware address(es) of this host, separated by spaces.
name String
Hostname to assign.

Import

Find the Terraform id from LuCI’s JSON-RPC API.

One way to find this information is with curl and jq:

curl \

--data '{"id": 0, "method": "foreach", "params": ["dhcp", "host"]}' \

http://192.168.1.1/cgi-bin/luci/rpc/uci?auth=$AUTH_TOKEN \

| jq '.result | map({terraformId: .[".name"]})'

This command will output something like:

[

{

"terraformId": "cfg123456",

}

]

We’d then use the information to import the appropriate resource:

$ pulumi import openwrt:index/dhcpHost:DhcpHost this cfg123456
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
openwrt joneshf/terraform-provider-openwrt
License
Notes
This Pulumi package is based on the openwrt Terraform Provider.