@@ -107,11 +107,11 @@ messages: []
107107hadErrors: false
108108` ` `
109109
110- # ## Example 3 - Generate network device IPs with range
110+ # ## Example 3 - Allocate IPs for network infrastructure
111111
112- The configuration uses the [`range()`][03] function to generate IP addresses
113- for multiple network devices systematically , demonstrating how to combine
114- functions for dynamic IP allocation .
112+ This configuration shows allocating specific IP addresses for various network
113+ infrastructure components within a subnet , demonstrating practical host number
114+ offsets for different device types .
115115
116116` ` ` yaml
117117# cidrHost.example.3.dsc.config.yaml
@@ -120,21 +120,19 @@ parameters:
120120 networkCidr:
121121 type: string
122122 defaultValue: 192.168.100.0/24
123- startHost:
124- type: int
125- defaultValue: 20
126- deviceCount:
127- type: int
128- defaultValue: 5
129123resources:
130- - name: Device IP allocation
124+ - name: Network infrastructure IPs
131125 type: Microsoft.DSC.Debug/Echo
132126 properties:
133127 output:
134128 network: "[parameters('networkCidr')]"
135129 gateway: "[cidrHost(parameters('networkCidr'), 1)]"
136- dnsServer: "[cidrHost(parameters('networkCidr'), 2)]"
137- deviceIPs: "[map(range(parameters('startHost'), parameters('deviceCount')), 'i', cidrHost(parameters('networkCidr'), add(i, parameters('startHost'))))]"
130+ primaryDNS: "[cidrHost(parameters('networkCidr'), 2)]"
131+ secondaryDNS: "[cidrHost(parameters('networkCidr'), 3)]"
132+ loadBalancer: "[cidrHost(parameters('networkCidr'), 10)]"
133+ webServer1: "[cidrHost(parameters('networkCidr'), 20)]"
134+ webServer2: "[cidrHost(parameters('networkCidr'), 21)]"
135+ dbServer: "[cidrHost(parameters('networkCidr'), 50)]"
138136` ` `
139137
140138` ` ` bash
@@ -143,20 +141,19 @@ dsc config get --file cidrHost.example.3.dsc.config.yaml
143141
144142` ` ` yaml
145143results:
146- - name: Device IP allocation
144+ - name: Network infrastructure IPs
147145 type: Microsoft.DSC.Debug/Echo
148146 result:
149147 actualState:
150148 output:
151149 network: 192.168.100.0/24
152150 gateway: 192.168.100.1
153- dnsServer: 192.168.100.2
154- deviceIPs:
155- - 192.168.100.20
156- - 192.168.100.21
157- - 192.168.100.22
158- - 192.168.100.23
159- - 192.168.100.24
151+ primaryDNS: 192.168.100.2
152+ secondaryDNS: 192.168.100.3
153+ loadBalancer: 192.168.100.10
154+ webServer1: 192.168.100.20
155+ webServer2: 192.168.100.21
156+ dbServer: 192.168.100.50
160157messages: []
161158hadErrors: false
162159` ` `
@@ -217,15 +214,13 @@ The `cidrHost()` function raises errors for the following conditions:
217214# # Related functions
218215
219216- [`cidrSubnet()`][02] - Creates a subnet from a larger CIDR block
220- - [`parseCidr()`][04] - Parses CIDR notation and returns network details
221- - [`range()`][03] - Generates a sequence of numbers
222- - [`map()`][05] - Applies a function to each element in an array
223- - [`parameters()`][06] - Retrieves parameter values
217+ - [`parseCidr()`][03] - Parses CIDR notation and returns network details
218+ - [`add()`][04] - Adds two numbers together
219+ - [`parameters()`][05] - Retrieves parameter values
224220
225221<!-- Link reference definitions -->
226222[01] : https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing
227223[02] : ./cidrSubnet.md
228- [03] : ./range.md
229- [04] : ./parseCidr.md
230- [05] : ./map.md
231- [06] : ./parameters.md
224+ [03] : ./parseCidr.md
225+ [04] : ./add.md
226+ [05] : ./parameters.md
0 commit comments