1# # @ohos.net.ethernet (Ethernet Connection Management)
2
3The **ethernet** module provides Ethernet management functions such as obtaining the network IP address.
4
5> **NOTE**
6> The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
7
8## Modules to Import
9
10```ts
11import { ethernet } from '@kit.NetworkKit';
12```
13
14## HttpProxy
15
16type HttpProxy = connection.HttpProxy;
17
18Defines the network proxy configuration.
19
20**System capability**: SystemCapability.Communication.NetManager.Ethernet
21
22| Type| Description                                      |
23| ------- | ----------------------------------------|
24| connection.HttpProxy     | Network proxy configuration.     |
25
26
27## ethernet.getMacAddress<sup>14+</sup>
28
29getMacAddress(): Promise\<Array\<MacAddressInfo>>
30
31Obtains the names and MAC addresses of all Ethernet NICs. This API uses a promise to return the result.
32
33**Required permission**: ohos.permission.GET_ETHERNET_LOCAL_MAC
34
35**System capability**: SystemCapability.Communication.NetManager.Ethernet
36
37**Return value**
38
39| Type                                                   | Description                              |
40|-------------------------------------------------------| ---------------------------------- |
41| Promise\<Array[\<MacAddressInfo>](#macaddressinfo14)> | Promise used to return the result.       |
42
43**Error codes**
44
45| ID| Error Message                                |
46| ------- | ----------------------------------------|
47| 201     | Permission denied.                      |
48| 2200002 | Failed to connect to the service.       |
49| 2201005 | Device information does not exist.  |
50
51**Example**
52
53```ts
54import { ethernet } from '@kit.NetworkKit';
55import { BusinessError } from '@kit.BasicServicesKit';
56
57ethernet.getMacAddress().then((data: Array<ethernet.MacAddressInfo>) => {
58  console.info("getMacAddress promise data = " + JSON.stringify(data));
59}).catch((error: BusinessError) => {
60  console.error("getMacAddress promise error = " + JSON.stringify(error));
61});
62```
63
64## MacAddressInfo<sup>14+</sup>
65Defines the name and MAC address of an Ethernet NIC.
66
67**System capability**: SystemCapability.Communication.NetManager.Ethernet
68
69| Name        | Type                   | Mandatory| Description                                                |
70| ------------ | ----------------------- | --- | ---------------------------------------------------- |
71| iface        | string                  |  Yes| Name of the Ethernet NIC.                                       |
72| macAddress       | string                |  Yes| MAC address of the Ethernet NIC.|
73