openwrt.NetworkInterface
Explore with Pulumi AI
A logic network.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as openwrt from "@pulumi/openwrt";
const brTesting = new openwrt.NetworkDevice("brTesting", {
    networkDeviceId: "br_testing",
    ports: [
        "eth0",
        "eth1",
        "eth2.20",
    ],
    type: "bridge",
});
const testing = new openwrt.NetworkInterface("testing", {
    device: brTesting.name,
    dns: [
        "9.9.9.9",
        "1.1.1.1",
    ],
    networkInterfaceId: "testing",
    ipaddr: "192.168.3.1",
    netmask: "255.255.255.0",
    proto: "static",
});
import pulumi
import pulumi_openwrt as openwrt
br_testing = openwrt.NetworkDevice("brTesting",
    network_device_id="br_testing",
    ports=[
        "eth0",
        "eth1",
        "eth2.20",
    ],
    type="bridge")
testing = openwrt.NetworkInterface("testing",
    device=br_testing.name,
    dns=[
        "9.9.9.9",
        "1.1.1.1",
    ],
    network_interface_id="testing",
    ipaddr="192.168.3.1",
    netmask="255.255.255.0",
    proto="static")
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 {
		brTesting, err := openwrt.NewNetworkDevice(ctx, "brTesting", &openwrt.NetworkDeviceArgs{
			NetworkDeviceId: pulumi.String("br_testing"),
			Ports: pulumi.StringArray{
				pulumi.String("eth0"),
				pulumi.String("eth1"),
				pulumi.String("eth2.20"),
			},
			Type: pulumi.String("bridge"),
		})
		if err != nil {
			return err
		}
		_, err = openwrt.NewNetworkInterface(ctx, "testing", &openwrt.NetworkInterfaceArgs{
			Device: brTesting.Name,
			Dns: pulumi.StringArray{
				pulumi.String("9.9.9.9"),
				pulumi.String("1.1.1.1"),
			},
			NetworkInterfaceId: pulumi.String("testing"),
			Ipaddr:             pulumi.String("192.168.3.1"),
			Netmask:            pulumi.String("255.255.255.0"),
			Proto:              pulumi.String("static"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Openwrt = Pulumi.Openwrt;
return await Deployment.RunAsync(() => 
{
    var brTesting = new Openwrt.NetworkDevice("brTesting", new()
    {
        NetworkDeviceId = "br_testing",
        Ports = new[]
        {
            "eth0",
            "eth1",
            "eth2.20",
        },
        Type = "bridge",
    });
    var testing = new Openwrt.NetworkInterface("testing", new()
    {
        Device = brTesting.Name,
        Dns = new[]
        {
            "9.9.9.9",
            "1.1.1.1",
        },
        NetworkInterfaceId = "testing",
        Ipaddr = "192.168.3.1",
        Netmask = "255.255.255.0",
        Proto = "static",
    });
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.openwrt.NetworkDevice;
import com.pulumi.openwrt.NetworkDeviceArgs;
import com.pulumi.openwrt.NetworkInterface;
import com.pulumi.openwrt.NetworkInterfaceArgs;
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 brTesting = new NetworkDevice("brTesting", NetworkDeviceArgs.builder()
            .networkDeviceId("br_testing")
            .ports(            
                "eth0",
                "eth1",
                "eth2.20")
            .type("bridge")
            .build());
        var testing = new NetworkInterface("testing", NetworkInterfaceArgs.builder()
            .device(brTesting.name())
            .dns(            
                "9.9.9.9",
                "1.1.1.1")
            .networkInterfaceId("testing")
            .ipaddr("192.168.3.1")
            .netmask("255.255.255.0")
            .proto("static")
            .build());
    }
}
resources:
  brTesting:
    type: openwrt:NetworkDevice
    properties:
      networkDeviceId: br_testing
      ports:
        - eth0
        - eth1
        - eth2.20
      type: bridge
  testing:
    type: openwrt:NetworkInterface
    properties:
      device: ${brTesting.name}
      dns:
        - 9.9.9.9
        - 1.1.1.1
      networkInterfaceId: testing
      ipaddr: 192.168.3.1
      netmask: 255.255.255.0
      proto: static
Create NetworkInterface Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new NetworkInterface(name: string, args: NetworkInterfaceArgs, opts?: CustomResourceOptions);@overload
def NetworkInterface(resource_name: str,
                     args: NetworkInterfaceArgs,
                     opts: Optional[ResourceOptions] = None)
@overload
def NetworkInterface(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     network_interface_id: Optional[str] = None,
                     device: Optional[str] = None,
                     proto: Optional[str] = None,
                     ipaddr: Optional[str] = None,
                     gateway: Optional[str] = None,
                     ip6assign: Optional[float] = None,
                     auto: Optional[bool] = None,
                     macaddr: Optional[str] = None,
                     mtu: Optional[float] = None,
                     netmask: Optional[str] = None,
                     dns: Optional[Sequence[str]] = None,
                     peerdns: Optional[bool] = None,
                     disabled: Optional[bool] = None,
                     reqaddress: Optional[str] = None,
                     reqprefix: Optional[str] = None)func NewNetworkInterface(ctx *Context, name string, args NetworkInterfaceArgs, opts ...ResourceOption) (*NetworkInterface, error)public NetworkInterface(string name, NetworkInterfaceArgs args, CustomResourceOptions? opts = null)
public NetworkInterface(String name, NetworkInterfaceArgs args)
public NetworkInterface(String name, NetworkInterfaceArgs args, CustomResourceOptions options)
type: openwrt:NetworkInterface
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args NetworkInterfaceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args NetworkInterfaceArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args NetworkInterfaceArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args NetworkInterfaceArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args NetworkInterfaceArgs
- 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 networkInterfaceResource = new Openwrt.NetworkInterface("networkInterfaceResource", new()
{
    NetworkInterfaceId = "string",
    Device = "string",
    Proto = "string",
    Ipaddr = "string",
    Gateway = "string",
    Ip6assign = 0,
    Auto = false,
    Macaddr = "string",
    Mtu = 0,
    Netmask = "string",
    Dns = new[]
    {
        "string",
    },
    Peerdns = false,
    Disabled = false,
    Reqaddress = "string",
    Reqprefix = "string",
});
example, err := openwrt.NewNetworkInterface(ctx, "networkInterfaceResource", &openwrt.NetworkInterfaceArgs{
	NetworkInterfaceId: pulumi.String("string"),
	Device:             pulumi.String("string"),
	Proto:              pulumi.String("string"),
	Ipaddr:             pulumi.String("string"),
	Gateway:            pulumi.String("string"),
	Ip6assign:          pulumi.Float64(0),
	Auto:               pulumi.Bool(false),
	Macaddr:            pulumi.String("string"),
	Mtu:                pulumi.Float64(0),
	Netmask:            pulumi.String("string"),
	Dns: pulumi.StringArray{
		pulumi.String("string"),
	},
	Peerdns:    pulumi.Bool(false),
	Disabled:   pulumi.Bool(false),
	Reqaddress: pulumi.String("string"),
	Reqprefix:  pulumi.String("string"),
})
var networkInterfaceResource = new NetworkInterface("networkInterfaceResource", NetworkInterfaceArgs.builder()
    .networkInterfaceId("string")
    .device("string")
    .proto("string")
    .ipaddr("string")
    .gateway("string")
    .ip6assign(0)
    .auto(false)
    .macaddr("string")
    .mtu(0)
    .netmask("string")
    .dns("string")
    .peerdns(false)
    .disabled(false)
    .reqaddress("string")
    .reqprefix("string")
    .build());
network_interface_resource = openwrt.NetworkInterface("networkInterfaceResource",
    network_interface_id="string",
    device="string",
    proto="string",
    ipaddr="string",
    gateway="string",
    ip6assign=0,
    auto=False,
    macaddr="string",
    mtu=0,
    netmask="string",
    dns=["string"],
    peerdns=False,
    disabled=False,
    reqaddress="string",
    reqprefix="string")
const networkInterfaceResource = new openwrt.NetworkInterface("networkInterfaceResource", {
    networkInterfaceId: "string",
    device: "string",
    proto: "string",
    ipaddr: "string",
    gateway: "string",
    ip6assign: 0,
    auto: false,
    macaddr: "string",
    mtu: 0,
    netmask: "string",
    dns: ["string"],
    peerdns: false,
    disabled: false,
    reqaddress: "string",
    reqprefix: "string",
});
type: openwrt:NetworkInterface
properties:
    auto: false
    device: string
    disabled: false
    dns:
        - string
    gateway: string
    ip6assign: 0
    ipaddr: string
    macaddr: string
    mtu: 0
    netmask: string
    networkInterfaceId: string
    peerdns: false
    proto: string
    reqaddress: string
    reqprefix: string
NetworkInterface 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 NetworkInterface resource accepts the following input properties:
- Device string
- NetworkInterface stringId 
- Name of the section. This name is only used when interacting with UCI directly.
- Proto string
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- Auto bool
- Specifies whether to bring up this interface on boot.
- Disabled bool
- Disables this interface.
- Dns List<string>
- DNS servers
- Gateway string
- Gateway of the interface
- Ip6assign double
- Delegate a prefix of given length to this interface
- Ipaddr string
- IP address of the interface
- Macaddr string
- Override the MAC Address of this interface.
- Mtu double
- Override the default MTU on this interface.
- Netmask string
- Netmask of the interface
- Peerdns bool
- Use DHCP-provided DNS servers.
- Reqaddress string
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- Reqprefix string
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- Device string
- NetworkInterface stringId 
- Name of the section. This name is only used when interacting with UCI directly.
- Proto string
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- Auto bool
- Specifies whether to bring up this interface on boot.
- Disabled bool
- Disables this interface.
- Dns []string
- DNS servers
- Gateway string
- Gateway of the interface
- Ip6assign float64
- Delegate a prefix of given length to this interface
- Ipaddr string
- IP address of the interface
- Macaddr string
- Override the MAC Address of this interface.
- Mtu float64
- Override the default MTU on this interface.
- Netmask string
- Netmask of the interface
- Peerdns bool
- Use DHCP-provided DNS servers.
- Reqaddress string
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- Reqprefix string
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- device String
- networkInterface StringId 
- Name of the section. This name is only used when interacting with UCI directly.
- proto String
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- auto Boolean
- Specifies whether to bring up this interface on boot.
- disabled Boolean
- Disables this interface.
- dns List<String>
- DNS servers
- gateway String
- Gateway of the interface
- ip6assign Double
- Delegate a prefix of given length to this interface
- ipaddr String
- IP address of the interface
- macaddr String
- Override the MAC Address of this interface.
- mtu Double
- Override the default MTU on this interface.
- netmask String
- Netmask of the interface
- peerdns Boolean
- Use DHCP-provided DNS servers.
- reqaddress String
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- reqprefix String
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- device string
- networkInterface stringId 
- Name of the section. This name is only used when interacting with UCI directly.
- proto string
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- auto boolean
- Specifies whether to bring up this interface on boot.
- disabled boolean
- Disables this interface.
- dns string[]
- DNS servers
- gateway string
- Gateway of the interface
- ip6assign number
- Delegate a prefix of given length to this interface
- ipaddr string
- IP address of the interface
- macaddr string
- Override the MAC Address of this interface.
- mtu number
- Override the default MTU on this interface.
- netmask string
- Netmask of the interface
- peerdns boolean
- Use DHCP-provided DNS servers.
- reqaddress string
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- reqprefix string
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- device str
- network_interface_ strid 
- Name of the section. This name is only used when interacting with UCI directly.
- proto str
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- auto bool
- Specifies whether to bring up this interface on boot.
- disabled bool
- Disables this interface.
- dns Sequence[str]
- DNS servers
- gateway str
- Gateway of the interface
- ip6assign float
- Delegate a prefix of given length to this interface
- ipaddr str
- IP address of the interface
- macaddr str
- Override the MAC Address of this interface.
- mtu float
- Override the default MTU on this interface.
- netmask str
- Netmask of the interface
- peerdns bool
- Use DHCP-provided DNS servers.
- reqaddress str
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- reqprefix str
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- device String
- networkInterface StringId 
- Name of the section. This name is only used when interacting with UCI directly.
- proto String
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- auto Boolean
- Specifies whether to bring up this interface on boot.
- disabled Boolean
- Disables this interface.
- dns List<String>
- DNS servers
- gateway String
- Gateway of the interface
- ip6assign Number
- Delegate a prefix of given length to this interface
- ipaddr String
- IP address of the interface
- macaddr String
- Override the MAC Address of this interface.
- mtu Number
- Override the default MTU on this interface.
- netmask String
- Netmask of the interface
- peerdns Boolean
- Use DHCP-provided DNS servers.
- reqaddress String
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- reqprefix String
- Behavior for requesting prefixes. Currently, only "auto" is supported.
Outputs
All input properties are implicitly available as output properties. Additionally, the NetworkInterface 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 NetworkInterface Resource
Get an existing NetworkInterface 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?: NetworkInterfaceState, opts?: CustomResourceOptions): NetworkInterface@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        auto: Optional[bool] = None,
        device: Optional[str] = None,
        disabled: Optional[bool] = None,
        dns: Optional[Sequence[str]] = None,
        gateway: Optional[str] = None,
        ip6assign: Optional[float] = None,
        ipaddr: Optional[str] = None,
        macaddr: Optional[str] = None,
        mtu: Optional[float] = None,
        netmask: Optional[str] = None,
        network_interface_id: Optional[str] = None,
        peerdns: Optional[bool] = None,
        proto: Optional[str] = None,
        reqaddress: Optional[str] = None,
        reqprefix: Optional[str] = None) -> NetworkInterfacefunc GetNetworkInterface(ctx *Context, name string, id IDInput, state *NetworkInterfaceState, opts ...ResourceOption) (*NetworkInterface, error)public static NetworkInterface Get(string name, Input<string> id, NetworkInterfaceState? state, CustomResourceOptions? opts = null)public static NetworkInterface get(String name, Output<String> id, NetworkInterfaceState state, CustomResourceOptions options)resources:  _:    type: openwrt:NetworkInterface    get:      id: ${id}- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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
- The unique name of the resulting resource.
- id
- 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.
- Auto bool
- Specifies whether to bring up this interface on boot.
- Device string
- Disabled bool
- Disables this interface.
- Dns List<string>
- DNS servers
- Gateway string
- Gateway of the interface
- Ip6assign double
- Delegate a prefix of given length to this interface
- Ipaddr string
- IP address of the interface
- Macaddr string
- Override the MAC Address of this interface.
- Mtu double
- Override the default MTU on this interface.
- Netmask string
- Netmask of the interface
- NetworkInterface stringId 
- Name of the section. This name is only used when interacting with UCI directly.
- Peerdns bool
- Use DHCP-provided DNS servers.
- Proto string
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- Reqaddress string
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- Reqprefix string
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- Auto bool
- Specifies whether to bring up this interface on boot.
- Device string
- Disabled bool
- Disables this interface.
- Dns []string
- DNS servers
- Gateway string
- Gateway of the interface
- Ip6assign float64
- Delegate a prefix of given length to this interface
- Ipaddr string
- IP address of the interface
- Macaddr string
- Override the MAC Address of this interface.
- Mtu float64
- Override the default MTU on this interface.
- Netmask string
- Netmask of the interface
- NetworkInterface stringId 
- Name of the section. This name is only used when interacting with UCI directly.
- Peerdns bool
- Use DHCP-provided DNS servers.
- Proto string
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- Reqaddress string
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- Reqprefix string
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- auto Boolean
- Specifies whether to bring up this interface on boot.
- device String
- disabled Boolean
- Disables this interface.
- dns List<String>
- DNS servers
- gateway String
- Gateway of the interface
- ip6assign Double
- Delegate a prefix of given length to this interface
- ipaddr String
- IP address of the interface
- macaddr String
- Override the MAC Address of this interface.
- mtu Double
- Override the default MTU on this interface.
- netmask String
- Netmask of the interface
- networkInterface StringId 
- Name of the section. This name is only used when interacting with UCI directly.
- peerdns Boolean
- Use DHCP-provided DNS servers.
- proto String
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- reqaddress String
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- reqprefix String
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- auto boolean
- Specifies whether to bring up this interface on boot.
- device string
- disabled boolean
- Disables this interface.
- dns string[]
- DNS servers
- gateway string
- Gateway of the interface
- ip6assign number
- Delegate a prefix of given length to this interface
- ipaddr string
- IP address of the interface
- macaddr string
- Override the MAC Address of this interface.
- mtu number
- Override the default MTU on this interface.
- netmask string
- Netmask of the interface
- networkInterface stringId 
- Name of the section. This name is only used when interacting with UCI directly.
- peerdns boolean
- Use DHCP-provided DNS servers.
- proto string
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- reqaddress string
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- reqprefix string
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- auto bool
- Specifies whether to bring up this interface on boot.
- device str
- disabled bool
- Disables this interface.
- dns Sequence[str]
- DNS servers
- gateway str
- Gateway of the interface
- ip6assign float
- Delegate a prefix of given length to this interface
- ipaddr str
- IP address of the interface
- macaddr str
- Override the MAC Address of this interface.
- mtu float
- Override the default MTU on this interface.
- netmask str
- Netmask of the interface
- network_interface_ strid 
- Name of the section. This name is only used when interacting with UCI directly.
- peerdns bool
- Use DHCP-provided DNS servers.
- proto str
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- reqaddress str
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- reqprefix str
- Behavior for requesting prefixes. Currently, only "auto" is supported.
- auto Boolean
- Specifies whether to bring up this interface on boot.
- device String
- disabled Boolean
- Disables this interface.
- dns List<String>
- DNS servers
- gateway String
- Gateway of the interface
- ip6assign Number
- Delegate a prefix of given length to this interface
- ipaddr String
- IP address of the interface
- macaddr String
- Override the MAC Address of this interface.
- mtu Number
- Override the default MTU on this interface.
- netmask String
- Netmask of the interface
- networkInterface StringId 
- Name of the section. This name is only used when interacting with UCI directly.
- peerdns Boolean
- Use DHCP-provided DNS servers.
- proto String
- The protocol type of the interface. Currently, only "dhcp, and "static" are supported.
- reqaddress String
- Behavior for requesting address. Can only be one of "force", "try", or "none".
- reqprefix String
- Behavior for requesting prefixes. Currently, only "auto" is supported.
Import
Find the Terraform id is the same as the UCI name from LuCI’s JSON-RPC API.
It is also generally the lower-cased version of the interface name in LuCI’s web UI.
One way to find this information is with curl and jq:
curl \
--data '{"id": 0, "method": "foreach", "params": ["network", "interface"]}' \
http://192.168.1.1/cgi-bin/luci/rpc/uci?auth=$AUTH_TOKEN \
| jq '.result | map(.[".name"])'
This command will output something like:
[
“loopback”,
“wan”,
“wan6”
]
We’d then use the information to import the appropriate resource:
$ pulumi import openwrt:index/networkInterface:NetworkInterface loopback loopback
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 openwrtTerraform Provider.