1# @ohos.enterprise.networkManager (Network Management) 2 3The **networkManager** module provides APIs for network management of enterprise devices, including obtaining the device IP address and MAC address. 4 5> **NOTE** 6> 7> The initial APIs of this module are supported since API version 12. Newly added APIs will be marked with a superscript to indicate their earliest API version. 8> 9> The APIs of this module can be used only in the stage model. 10> 11> The APIs of this module can be called only by a [device administrator application](../../mdm/mdm-kit-guide.md#introduction) that is enabled. 12> 13 14## Modules to Import 15 16```ts 17import { networkManager } from '@kit.MDMKit'; 18``` 19 20## networkManager.getAllNetworkInterfacesSync 21 22getAllNetworkInterfacesSync(admin: Want): Array<string> 23 24Obtains all activated network ports through the specified device administrator application. 25 26**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 27 28**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 29 30 31**Parameters** 32 33| Name| Type | Mandatory| Description | 34| ------ | ------------------------------------------------------- | ---- | -------------- | 35| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 36 37**Return value** 38 39| Type | Description | 40| ------------------- | ---------------------- | 41| Array<string> | Network ports obtained.| 42 43**Error codes** 44 45For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 46 47| ID| Error Message | 48| -------- | ------------------------------------------------------------ | 49| 9200001 | The application is not an administrator application of the device. | 50| 9200002 | The administrator application does not have permission to manage the device. | 51| 201 | Permission verification failed. The application does not have the permission required to call the API. | 52| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 53 54**Example** 55 56```ts 57import { Want } from '@kit.AbilityKit'; 58let wantTemp: Want = { 59 bundleName: 'com.example.myapplication', 60 abilityName: 'EntryAbility', 61}; 62 63try { 64 let result: Array<string> = networkManager.getAllNetworkInterfacesSync(wantTemp); 65 console.info(`Succeeded in getting all network interfaces, result : ${JSON.stringify(result)}`); 66} catch (err) { 67 console.error(`Failed to get all network interfaces. Code: ${err.code}, message: ${err.message}`); 68} 69``` 70 71## networkManager.getIpAddressSync 72 73getIpAddressSync(admin: Want, networkInterface: string): string 74 75Obtains the device IP address based on the network port through the specified device administrator application. 76 77**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 78 79**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 80 81 82**Parameters** 83 84| Name | Type | Mandatory| Description | 85| ---------------- | ------------------------------------------------------- | ---- | -------------- | 86| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 87| networkInterface | string | Yes | Network port.| 88 89**Return value** 90 91| Type | Description | 92| ------ | ---------------- | 93| string | Device IP address obtained.| 94 95**Error codes** 96 97For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 98 99| ID| Error Message | 100| -------- | ------------------------------------------------------------ | 101| 9200001 | The application is not an administrator application of the device. | 102| 9200002 | The administrator application does not have permission to manage the device. | 103| 201 | Permission verification failed. The application does not have the permission required to call the API. | 104| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 105 106**Example** 107 108```ts 109import { Want } from '@kit.AbilityKit'; 110let wantTemp: Want = { 111 bundleName: 'com.example.myapplication', 112 abilityName: 'EntryAbility', 113}; 114 115try { 116 let result: string = networkManager.getIpAddressSync(wantTemp, 'eth0'); 117 console.info(`Succeeded in getting ip address, result : ${result}`); 118} catch (err) { 119 console.error(`Failed to get ip address. Code: ${err.code}, message: ${err.message}`); 120} 121``` 122 123## networkManager.getMacSync 124 125getMacSync(admin: Want, networkInterface: string): string 126 127Obtains the device MAC address based on the network port through the specified device administrator application. 128 129**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 130 131**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 132 133 134**Parameters** 135 136| Name | Type | Mandatory| Description | 137| ---------------- | ------------------------------------------------------- | ---- | -------------- | 138| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 139| networkInterface | string | Yes | Network port.| 140 141**Return value** 142 143| Type | Description | 144| ------ | ----------------- | 145| string | Device MAC address obtained.| 146 147**Error codes** 148 149For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 150 151| ID| Error Message | 152| -------- | ------------------------------------------------------------ | 153| 9200001 | The application is not an administrator application of the device. | 154| 9200002 | The administrator application does not have permission to manage the device. | 155| 201 | Permission verification failed. The application does not have the permission required to call the API. | 156| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 157 158**Example** 159 160```ts 161import { Want } from '@kit.AbilityKit'; 162let wantTemp: Want = { 163 bundleName: 'com.example.myapplication', 164 abilityName: 'EntryAbility', 165}; 166 167try { 168 let result: string = networkManager.getMacSync(wantTemp, 'eth0'); 169 console.info(`Succeeded in getting mac, result : ${result}`); 170} catch (err) { 171 console.error(`Failed to get mac. Code: ${err.code}, message: ${err.message}`); 172} 173``` 174 175## networkManager.isNetworkInterfaceDisabledSync 176 177isNetworkInterfaceDisabledSync(admin: Want, networkInterface: string): boolean 178 179Checks whether a network port is disabled through the specified device administrator application. 180 181**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 182 183**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 184 185 186**Parameters** 187 188| Name | Type | Mandatory| Description | 189| ---------------- | ------------------------------------------------------- | ---- | -------------- | 190| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 191| networkInterface | string | Yes | Network port.| 192 193**Return value** 194 195| Type | Description | 196| ------- | ------------------------------------------------------------ | 197| boolean | Returns **true** if the network port is disabled; returns **false** otherwise.| 198 199**Error codes** 200 201For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 202 203| ID| Error Message | 204| -------- | ------------------------------------------------------------ | 205| 9200001 | The application is not an administrator application of the device. | 206| 9200002 | The administrator application does not have permission to manage the device. | 207| 201 | Permission verification failed. The application does not have the permission required to call the API. | 208| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 209 210**Example** 211 212```ts 213import { Want } from '@kit.AbilityKit'; 214let wantTemp: Want = { 215 bundleName: 'com.example.myapplication', 216 abilityName: 'EntryAbility', 217}; 218 219try { 220 let result: boolean = networkManager.isNetworkInterfaceDisabledSync(wantTemp, 'eth0'); 221 console.info(`Succeeded in querying network interface is disabled or not, result : ${result}`); 222} catch (err) { 223 console.error(`Failed to query network interface is disabled or not. Code: ${err.code}, message: ${err.message}`); 224} 225``` 226 227## networkManager.setNetworkInterfaceDisabledSync 228 229setNetworkInterfaceDisabledSync(admin: Want, networkInterface: string, isDisabled: boolean): void 230 231Disables a network port through the specified device administrator application. 232 233**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 234 235**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 236 237 238**Parameters** 239 240| Name | Type | Mandatory| Description | 241| ---------------- | ------------------------------------------------------- | ---- | ------------------------------------------------- | 242| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 243| networkInterface | string | Yes | Network port. | 244| isDisabled | boolean | Yes | Network port status to set. The value **true** means to disable the network port, and **false** means to enable the network port.| 245 246**Error codes** 247 248For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 249 250| ID| Error Message | 251| -------- | ------------------------------------------------------------ | 252| 9200001 | The application is not an administrator application of the device. | 253| 9200002 | The administrator application does not have permission to manage the device. | 254| 201 | Permission verification failed. The application does not have the permission required to call the API. | 255| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 256 257**Example** 258 259```ts 260import { Want } from '@kit.AbilityKit'; 261import { BusinessError } from '@kit.BasicServicesKit'; 262let wantTemp: Want = { 263 bundleName: 'com.example.myapplication', 264 abilityName: 'EntryAbility', 265}; 266 267try { 268 networkManager.setNetworkInterfaceDisabledSync(wantTemp, 'eth0', true); 269 console.info(`Succeeded in setting network interface disabled`); 270} catch (err) { 271 console.error(`Failed to set network interface disabled. Code: ${err.code}, message: ${err.message}`); 272} 273``` 274 275## networkManager.setGlobalProxySync 276 277setGlobalProxySync(admin: Want, httpProxy: connection.HttpProxy): void 278 279Sets the global network proxy through the specified device administrator application. 280 281**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 282 283**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 284 285 286**Parameters** 287 288| Name | Type | Mandatory| Description | 289| --------- | ------------------------------------------------------------ | ---- | -------------------------- | 290| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 291| httpProxy | [connection.HttpProxy](../apis-network-kit/js-apis-net-connection.md#httpproxy10) | Yes | Global HTTP proxy to set.| 292 293**Error codes** 294 295For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 296 297| ID| Error Message | 298| -------- | ------------------------------------------------------------ | 299| 9200001 | The application is not an administrator application of the device. | 300| 9200002 | The administrator application does not have permission to manage the device. | 301| 201 | Permission verification failed. The application does not have the permission required to call the API. | 302| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 303 304**Example** 305 306```ts 307import { Want } from '@kit.AbilityKit'; 308import { connection } from '@kit.NetworkKit'; 309let wantTemp: Want = { 310 bundleName: 'com.example.myapplication', 311 abilityName: 'EntryAbility', 312}; 313let exclusionStr: string = "192.168,baidu.com" 314let exclusionArray: Array<string> = exclusionStr.split(','); 315let httpProxy: connection.HttpProxy = { 316 host: "192.168.xx.xxx", 317 port: 8080, 318 exclusionList: exclusionArray 319}; 320 321try { 322 networkManager.setGlobalProxySync(wantTemp, httpProxy); 323 console.info(`Succeeded in setting network global proxy.`); 324} catch (err) { 325 console.error(`Failed to set network global proxy. Code: ${err.code}, message: ${err.message}`); 326} 327``` 328 329## networkManager.getGlobalProxySync 330 331getGlobalProxySync(admin: Want): connection.HttpProxy 332 333Obtains the global network proxy through the specified device administrator application. 334 335**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 336 337**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 338 339 340**Parameters** 341 342| Name| Type | Mandatory| Description | 343| ------ | ------------------------------------------------------- | ---- | -------------- | 344| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 345 346**Return value** 347 348| Type | Description | 349| ------------------------------------------------------------ | ------------------------------ | 350| [connection.HttpProxy](../apis-network-kit/js-apis-net-connection.md#httpproxy10) | Global HTTP proxy configuration obtained.| 351 352**Error codes** 353 354For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 355 356| ID| Error Message | 357| -------- | ------------------------------------------------------------ | 358| 9200001 | The application is not an administrator application of the device. | 359| 9200002 | The administrator application does not have permission to manage the device. | 360| 201 | Permission verification failed. The application does not have the permission required to call the API. | 361| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 362 363**Example** 364 365```ts 366import { Want } from '@kit.AbilityKit'; 367import { BusinessError } from '@kit.BasicServicesKit'; 368import { connection } from '@kit.NetworkKit'; 369let wantTemp: Want = { 370 bundleName: 'com.example.myapplication', 371 abilityName: 'EntryAbility', 372}; 373 374try { 375 let result: connection.HttpProxy = networkManager.getGlobalProxySync(wantTemp); 376 console.info(`Succeeded in getting network global proxy, result : ${JSON.stringify(result)}`); 377} catch (err) { 378 console.error(`Failed to get network global proxy. Code: ${err.code}, message: ${err.message}`); 379} 380``` 381 382## networkManager.addFirewallRule 383 384addFirewallRule(admin: Want, firewallRule: FirewallRule): void 385 386Adds a firewall rule for devices through the specified device administrator application.<br> 387After a rule with [Action](#action) set to **ALLOW** is added, a rule with **Action** set to **DENY** is added by default to discard or intercept all network data packets that do not meet the **ALLOW** rule. 388 389**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 390 391**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 392 393 394**Parameters** 395 396| Name | Type | Mandatory| Description | 397| ------------ | ------------------------------------------------------- | ---- | -------------------- | 398| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 399| firewallRule | [FirewallRule](#firewallrule) | Yes | Firewall rule to add.| 400 401**Error codes** 402 403For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 404 405| ID| Error Message | 406| -------- | ------------------------------------------------------------ | 407| 9200001 | The application is not an administrator application of the device. | 408| 9200002 | The administrator application does not have permission to manage the device. | 409| 201 | Permission verification failed. The application does not have the permission required to call the API. | 410| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 411 412**Example** 413 414```ts 415import { Want } from '@kit.AbilityKit'; 416 417let wantTemp: Want = { 418 bundleName: 'com.example.myapplication', 419 abilityName: 'EntryAbility', 420}; 421let firewallRule: networkManager.FirewallRule = { 422 "srcAddr": "192.168.1.1-192.188.22.66", 423 "destAddr": "10.1.1.1", 424 "srcPort": "8080", 425 "destPort": "8080", 426 "appUid": "9696", 427 "direction": networkManager.Direction.OUTPUT, 428 "action": networkManager.Action.DENY, 429 "protocol": networkManager.Protocol.UDP, 430} 431 432networkManager.addFirewallRule(wantTemp, firewallRule); 433``` 434 435## networkManager.removeFirewallRule 436 437removeFirewallRule(admin: Want, firewallRule?: FirewallRule): void 438 439Removes a firewall rule for devices through the specified device administrator application.<br> 440If there is no rule with [Action](#action) being **ALLOW** after the rule is removed, the **DENY** rules that are added by default with [addFirewallRule](#networkmanageraddfirewallrule) will be removed. 441 442**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 443 444**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 445 446 447**Parameters** 448 449| Name | Type | Mandatory| Description | 450| ------------ | ------------------------------------------------------- | ---- | ---------------------------------------------------- | 451| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 452| firewallRule | [FirewallRule](#firewallrule) | No | Firewall rule to remove. If the value is empty, all firewall rules will be removed.| 453 454**Error codes** 455 456For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 457 458| ID| Error Message | 459| -------- | ------------------------------------------------------------ | 460| 9200001 | The application is not an administrator application of the device. | 461| 9200002 | The administrator application does not have permission to manage the device. | 462| 201 | Permission verification failed. The application does not have the permission required to call the API. | 463| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 464 465**Example** 466 467```ts 468import { Want } from '@kit.AbilityKit'; 469 470let wantTemp: Want = { 471 bundleName: 'com.example.myapplication', 472 abilityName: 'EntryAbility', 473}; 474// Remove the specified firewall rule. 475let firewallRule: networkManager.FirewallRule = { 476 "srcAddr": "192.168.1.1-192.188.22.66", 477 "destAddr": "10.1.1.1", 478 "srcPort": "8080", 479 "destPort": "8080", 480 "appUid": "9696", 481 "direction": networkManager.Direction.OUTPUT, 482 "action": networkManager.Action.DENY, 483 "protocol": networkManager.Protocol.UDP, 484} 485networkManager.removeFirewallRule(wantTemp, firewallRule); 486 487// Remove all firewall rules. 488networkManager.removeFirewallRule(wantTemp); 489``` 490 491## networkManager.getFirewallRules 492 493getFirewallRules(admin: Want): Array\<FirewallRule> 494 495Obtains firewall rules through the specified device administrator application. 496 497**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 498 499**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 500 501 502**Parameters** 503 504| Name| Type | Mandatory| Description | 505| ------ | ------------------------------------------------------- | ---- | -------------- | 506| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 507 508**Return value** 509 510| Type | Description | 511| ------------------------------------- | ------------------------------------------------------------ | 512| Array\<[FirewallRule](#firewallrule)> | A list of firewall rules configured for the device is returned. If the operation fails, an exception will be thrown.| 513 514**Error codes** 515 516For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 517 518| ID| Error Message | 519| -------- | ------------------------------------------------------------ | 520| 9200001 | The application is not an administrator application of the device. | 521| 9200002 | The administrator application does not have permission to manage the device. | 522| 201 | Permission verification failed. The application does not have the permission required to call the API. | 523| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 524 525**Example** 526 527```ts 528import { Want } from '@kit.AbilityKit'; 529 530let wantTemp: Want = { 531 bundleName: 'com.example.myapplication', 532 abilityName: 'EntryAbility', 533}; 534let firewallRule: Array<networkManager.FirewallRule>; 535firewallRule = networkManager.getFirewallRules(wantTemp); 536``` 537 538## networkManager.addDomainFilterRule 539 540addDomainFilterRule(admin: Want, domainFilterRule: DomainFilterRule): void 541 542Adds a domain name filtering rule for the device through the specified device administrator application.<br> 543After a rule with [Action](#action) set to **ALLOW** is added, a rule with **Action** set to **DENY** is added by default to discard or intercept all packets for domain name resolution that do not meet the **ALLOW** rule. 544 545**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 546 547**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 548 549 550**Parameters** 551 552| Name | Type | Mandatory| Description | 553| ---------------- | ------------------------------------------------------- | ---- | ------------------ | 554| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 555| domainFilterRule | [DomainFilterRule](#domainfilterrule) | Yes | Domain name filtering rule to add.| 556 557**Error codes** 558 559For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 560 561| ID| Error Message | 562| -------- | ------------------------------------------------------------ | 563| 9200001 | The application is not an administrator application of the device. | 564| 9200002 | The administrator application does not have permission to manage the device. | 565| 201 | Permission verification failed. The application does not have the permission required to call the API. | 566| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 567 568**Example** 569 570```ts 571import { Want } from '@kit.AbilityKit'; 572 573let wantTemp: Want = { 574 bundleName: 'com.example.myapplication', 575 abilityName: 'EntryAbility', 576}; 577let domainFilterRule: networkManager.DomainFilterRule = { 578 "domainName": "www.example.com", 579 "appUid": "9696", 580 "action": networkManager.Action.DENY, 581} 582 583networkManager.addDomainFilterRule(wantTemp, domainFilterRule); 584``` 585 586## networkManager.removeDomainFilterRule 587 588removeDomainFilterRule(admin: Want, domainFilterRule?: DomainFilterRule): void 589 590Removes a domain name filtering rule through the specified device administrator application.<br> 591If there is no rule with [Action](#action) being **ALLOW** after the rule is removed, the **DENY** rules that are added by default with [addDomainFilterRule](#networkmanageradddomainfilterrule) will be removed. 592 593**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 594 595**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 596 597 598**Parameters** 599 600| Name | Type | Mandatory| Description | 601| ---------------- | ------------------------------------------------------- | ---- | ------------------------------------------------ | 602| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application. | 603| domainFilterRule | [DomainFilterRule](#domainfilterrule) | No | Domain name filtering rule to remove. If the value is empty, all domain name filtering rules will be removed.| 604 605**Error codes** 606 607For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 608 609| ID| Error Message | 610| -------- | ------------------------------------------------------------ | 611| 9200001 | The application is not an administrator application of the device. | 612| 9200002 | The administrator application does not have permission to manage the device. | 613| 201 | Permission verification failed. The application does not have the permission required to call the API. | 614| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 615 616**Example** 617 618```ts 619import { Want } from '@kit.AbilityKit'; 620 621let wantTemp: Want = { 622 bundleName: 'com.example.myapplication', 623 abilityName: 'EntryAbility', 624}; 625// Remove the specified domain name filtering rule. 626let domainFilterRule: networkManager.DomainFilterRule = { 627 "domainName": "www.example.com", 628 "appUid": "9696", 629 "action": networkManager.Action.DENY, 630} 631networkManager.removeDomainFilterRule(wantTemp, domainFilterRule); 632 633// Remove all domain name filtering rules. 634networkManager.removeDomainFilterRule(wantTemp); 635``` 636 637## networkManager.getDomainFilterRules 638 639getDomainFilterRules(admin: Want): Array\<DomainFilterRule> 640 641Obtains domain name filtering rules through the specified device administrator application. 642 643**Required permissions**: ohos.permission.ENTERPRISE_MANAGE_NETWORK 644 645**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 646 647 648**Parameters** 649 650| Name| Type | Mandatory| Description | 651| ------ | ------------------------------------------------------- | ---- | -------------- | 652| admin | [Want](../apis-ability-kit/js-apis-app-ability-want.md) | Yes | Device administrator application.| 653 654**Return value** 655 656| Type | Description | 657| --------------------------------------------- | ------------------------------------------------------------ | 658| Array\<[DomainFilterRule](#domainfilterrule)> | A list of domain name filtering rules configured for the device is returned. If the operation fails, an exception will be thrown.| 659 660**Error codes** 661 662For details about the error codes, see [Enterprise Device Management Error Codes](errorcode-enterpriseDeviceManager.md) and [Universal Error Codes](../errorcode-universal.md). 663 664| ID| Error Message | 665| -------- | ------------------------------------------------------------ | 666| 9200001 | The application is not an administrator application of the device. | 667| 9200002 | The administrator application does not have permission to manage the device. | 668| 201 | Permission verification failed. The application does not have the permission required to call the API. | 669| 401 | Parameter error. Possible causes: 1. Mandatory parameters are left unspecified; 2. Incorrect parameter types; 3. Parameter verification failed. | 670 671**Example** 672 673```ts 674import { Want } from '@kit.AbilityKit'; 675 676let wantTemp: Want = { 677 bundleName: 'com.example.myapplication', 678 abilityName: 'EntryAbility', 679}; 680let domainFilterRule: Array<networkManager.DomainFilterRule>; 681domainFilterRule = networkManager.getDomainFilterRules(wantTemp); 682``` 683 684## FirewallRule 685 686Represents a firewall rule. 687 688**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 689 690 691| Name | Type | Mandatory| Description | 692| --------- | ----------------------- | ---- | ------------------------------------------------------------ | 693| srcAddr | string | No | Source IP address. An IP address segment, for example, **192.168.0.0/22** or **192.168.1.100-192.168.1.200** is supported.| 694| destAddr | string | No | Destination IP address. An IP address segment, for example, **192.168.0.0/22** or **192.168.1.100-192.168.1.200** is supported.| 695| srcPort | string | No | Source port. | 696| destPort | string | No | Destination port. | 697| appUid | string | No | UID of the application. | 698| direction | [Direction](#direction) | No | Direction chains to which the rule applies.<br>This parameter is mandatory when you add a firewall rule. If it is not specified when you remove a firewall rule, all [direction](#direction) chains will be removed.<br>If this parameter is empty, **srcAddr**, **destAddr**, **srcPort**, **destPort**, and **appUid** must also be empty.| 699| action | [Action](#action) | No | Action to take, that is, receive or discard data packets.<br>This parameter is mandatory when a firewall rule is added. It is optional when a firewall rule is removed. If it is not specified, all chains that match the [Action](#action) rule will be removed.<br>If this parameter is empty, **srcAddr**, **destAddr**, **srcPort**, **destPort**, and **appUid** must also be empty.| 700| protocol | [Protocol](#protocol) | No | Network protocol. If this parameter is set to **ALL** or **ICMP**, **srcPort** and **destPort** cannot be set.| 701 702## DomainFilterRule 703 704Represents a domain name filtering rule. 705 706**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 707 708 709| Name | Type | Mandatory| Description | 710| ---------- | ----------------- | ---- | ------------------------------------------------------------ | 711| domainName | string | No | Domain name. This parameter is mandatory when a domain name filtering rule is added. | 712| appUid | string | No | UID of the application. | 713| action | [Action](#action) | No | Action to take, that is, receive or discard data packets.<br>This parameter is mandatory when you add a domain name filtering rule. If it is not specified when you remove a domain name filtering rule, all chains that match the [Action](#action) rule will be removed.<br>If this parameter is empty, **domainName** and **appUid** must also be empty.| 714 715## Direction 716 717Direction chains to which the rule applies. 718 719**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 720 721 722| Name | Value | Description | 723| ------ | ---- | -------- | 724| INPUT | 0 | Input chain.| 725| OUTPUT | 1 | Output chain.| 726 727## Action 728 729Enumerates the actions that can be taken for data packets. 730 731**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 732 733 734| Name | Value | Description | 735| ----- | ---- | ------------ | 736| ALLOW | 0 | Receive data packets.| 737| DENY | 1 | Discard data packets.| 738 739## Protocol 740 741Network protocol. 742 743**System capability**: SystemCapability.Customization.EnterpriseDeviceManager 744 745 746| Name| Value | Description | 747| ---- | ---- | -------------- | 748| ALL | 0 | All network protocols.| 749| TCP | 1 | TCP. | 750| UDP | 2 | UDP. | 751| ICMP | 3 | ICMP.| 752