1# Network Management
2
3## Overview
4
5A Network Manager is a daemon which handles network management operations.
6It must implement the
7`xyz.openbmc_project.Network.SystemConfiguration.interface` and
8`org.freedesktop.DBus.ObjectManager`.
9
10When the network manager daemon comes up, it should create objects
11implementing physical link/virtual interfaces such as
12`xyz.openbmc_project.Network.EthernetInterface` or
13`xyz.openbmc_project.Network.VLANInterface` on the system.
14
15IP address(v4 and v6) objects must be children objects of the
16physical/virtual interface object.
17
18## Interfaces
19
201. SystemConfiguration: This describes the system-specific parameters.
212. EthernetInterface: This describes the interface specific parameters.
223. IP: This describes the IP address specific parameters.
234. IPProtocol: This describes the IP protocol type(IPv4/IPv6).
245. VLANInterface: This describes the VLAN specific properties.
256. Bond: This describes the interface bonding parameters.
26
27## D-Bus Objects
28
29### Interface Objects
30
31Interface objects can be physical as well as virtual.
32
33If the object is a physical interface, it can't be deleted,
34but if it is a virtual interface object it can be deleted.
35
36E.g. `/xyz/openbmc_project/network/<interfacename>`
37
38### IP Address Objects
39
40There can be multiple IP address objects under an interface object.
41These objects can be deleted by the delete function.
42
43IPv4 objects will have the following D-Bus object path:
44
45`/xyz/openbmc_project/network/<interface>/ipv4/<id>`
46
47IPv6 objects will have the following D-Bus object path:
48
49`/xyz/openbmc_project/network/<interface>/ipv6/<id>`
50
51### Network Configuration Object
52
53The network configuration object will have system configuration parameters:
54
55`/xyz/openbmc_project/network/conf`
56
57## Commands
58
59### Create Static IPv4 Address
60
61```sh
62busctl call xyz.openbmc_project.Network \
63    /xyz/openbmc_project/network/<interface> \
64    xyz.openbmc_project.Network.IP.Create \
65    IP ssys "xyz.openbmc_project.Network.IP.Protocol.IPv4" \
66    "<IP Address>" <Netmask Prefix> "<Network Gateway>"
67```
68
69```sh
70curl -c cjar -b cjar -k -H "Content-Type: application/json" -X  POST \
71    -d '{
72            "data": [
73                "xyz.openbmc_project.Network.IP.Protocol.IPv4",
74                "<IP Address",
75                <Netmask Prefix>,
76                "<Network Gateway>"
77            ]
78        }' \
79    https://${bmc}/xyz/openbmc_project/network/<interface>/action/IP
80```
81
82E.g.
83
84```sh
85curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST \
86    -d '{
87            "data": [
88                "xyz.openbmc_project.Network.IP.Protocol.IPv4",
89                "8.8.8.8",
90                24,
91                "8.8.8.0"
92            ]
93        }' \
94    https://${bmc}/xyz/openbmc_project/network/eth0/action/IP
95```
96
97Note: After creating the IP address object enumerate the network interface
98object to get the IPv4 id.
99
100### Delete IPv4 Address
101
102```sh
103busctl call xyz.openbmc_project.Network \
104    /xyz/openbmc_project/network/<interface>/ipv4/<id> \
105    xyz.openbmc_project.Object.Delete Delete
106```
107
108```sh
109curl -c cjar -b cjar -k -H "Content-Type: application/json" -X DELETE \
110    https://${bmc}/xyz/openbmc_project/network/<interface>/ipv4/<id>
111```
112
113### Default Gateway
114
115#### Get
116
117```sh
118busctl get-property xyz.openbmc_project.Network \
119    /xyz/openbmc_project/network/config \
120    xyz.openbmc_project.Network.SystemConfiguration DefaultGateway
121```
122
123```sh
124curl -c cjar -b cjar -k -H "Content-Type: application/json" \
125    https://${bmc}/xyz/openbmc_project/network/config/attr/DefaultGateway
126```
127
128#### Set
129
130```sh
131busctl set-property xyz.openbmc_project.Network \
132    /xyz/openbmc_project/network/config \
133    xyz.openbmc_project.Network.SystemConfiguration \
134    DefaultGateway s "<DefaultGateway>"
135```
136
137```sh
138curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT \
139    -d '{"data": "<DefaultGateway>"}' \
140    https://${bmc}/xyz/openbmc_project/network/config/attr/DefaultGateway
141```
142
143NOTE: The default gateway must be pingable, if not 0.0.0.0 will be used.
144
145### HostName
146
147#### Get
148
149```sh
150busctl get-property xyz.openbmc_project.Network \
151    /xyz/openbmc_project/network/config \
152    xyz.openbmc_project.Network.SystemConfiguration HostName
153```
154
155```sh
156curl -c cjar -b cjar -k -H "Content-Type: application/json" \
157    https://${bmc}/xyz/openbmc_project/network/config/attr/HostName
158```
159
160#### Set
161
162```sh
163busctl set-property xyz.openbmc_project.Network \
164    /xyz/openbmc_project/network/config \
165    xyz.openbmc_project.Network.SystemConfiguration HostName s "<HostName>"
166```
167
168```sh
169curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT \
170    -d '{"data": "<HostName>"}' \
171    https://${bmc}/xyz/openbmc_project/network/config/attr/HostName
172```
173
174### DHCP
175
176#### Get
177
178```sh
179busctl get-property xyz.openbmc_project.Network \
180    /xyz/openbmc_project/network/eth0 \
181    xyz.openbmc_project.Network.EthernetInterface DHCPEnabled
182```
183
184```sh
185curl -c cjar -b cjar -k -H "Content-Type: application/json" \
186    https://${bmc}/xyz/openbmc_project/network/eth0/attr/DHCPEnabled
187```
188
189#### Enable
190
191```sh
192busctl set-property xyz.openbmc_project.Network \
193    /xyz/openbmc_project/network/eth0 \
194    xyz.openbmc_project.Network.EthernetInterface DHCPEnabled b 1
195```
196
197```sh
198curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT \
199    -d '{"data": 1}' \
200    https://${bmc}/xyz/openbmc_project/network/eth0/attr/DHCPEnabled
201```
202
203### MAC Address
204
205#### Get
206
207```sh
208busctl get-property xyz.openbmc_project.Network \
209    /xyz/openbmc_project/network/eth0 \
210    xyz.openbmc_project.Network.MACAddress MACAddress
211```
212
213```sh
214curl -c cjar -b cjar -k -H "Content-Type: application/json" \
215    https://${bmc}/xyz/openbmc_project/network/<interface>/attr/MACAddress
216```
217
218#### Set
219
220```sh
221busctl set-property xyz.openbmc_project.Network \
222    /xyz/openbmc_project/network/<interface> \
223    xyz.openbmc_project.Network.MACAddress MACAddress s "<MAC Address>"
224```
225
226```sh
227curl -c cjar -b cjar -k -H "Content-Type: application/json" -X PUT \
228    -d '{"data": "<MAC Address>" }' \
229    https://${bmc}/xyz/openbmc_project/network/<interface>/attr/MACAddress
230```
231
232NOTE: MAC address should be a local admin MAC (2nd bit of first byte should be
233on).
234
235### Network Factory Reset
236
237```sh
238busctl call xyz.openbmc_project.Network /xyz/openbmc_project/network \
239    xyz.openbmc_project.Common.FactoryReset Reset
240```
241
242```sh
243curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST \
244    -d '{"data":[] }' https://${bmc}/xyz/openbmc_project/network/action/Reset
245```
246
247### VLAN
248
249#### Create
250
251```sh
252busctl call xyz.openbmc_project.Network /xyz/openbmc_project/network \
253    xyz.openbmc_project.Network.VLAN.Create VLAN su "<interface>" <VLAN id>
254```
255
256```sh
257curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST \
258    -d '{"data":["<interface>", <VLAN id>] }' \
259    https://${bmc}/xyz/openbmc_project/network/action/VLAN
260```
261
262E.g.
263
264```sh
265curl -c cjar -b cjar -k -H "Content-Type: application/json" -X POST \
266    -d '{"data":["eth0",50] }' \
267    https://${bmc}/xyz/openbmc_project/network/action/VLAN
268```
269
270#### Delete
271
272```sh
273busctl call xyz.openbmc_project.Network \
274    /xyz/openbmc_project/network/<VLAN interface> \
275    xyz.openbmc_project.Object.Delete Delete
276```
277
278```sh
279curl -c cjar -b cjar -k -H "Content-Type: application/json" -X DELETE \
280    https://${bmc}/xyz/openbmc_project/network/<VLAN interface>
281```
282
283E.g.
284
285```sh
286curl -c cjar -b cjar -k -H "Content-Type: application/json" -X DELETE \
287    https://${bmc}/xyz/openbmc_project/network/eth0_50
288```
289
290#### Enumerate
291
292```sh
293curl -c cjar -b cjar -k -H "Content-Type: application/json" \
294    https://${bmc}/xyz/openbmc_project/network/<VLAN interface>/enumerate
295```
296
297### IPMI VLAN and IP
298
299#### Create
300
301```sh
302ipmitool -I dbus lan set 1 ipsrc static
303
304ipmitool -I dbus lan set 1 ipaddr <IP address>
305
306ipmitool -I dbus lan set 1 netmask <mask>
307
308ipmitool -I dbus lan set 1 defgw ipaddr <IP address>
309
310ipmitool -I dbus lan set 1 vlan id <id>
311
312ipmitool -I dbus raw 0x06 0x40 // To the save settings
313```
314
315NOTE: It takes 4-5 seconds to create the VLAN and configure the IP.
316If a VLAN interface is not desired don't set the VLAN id above.
317
318#### Delete
319
320```sh
321ipmitool -I dbus lan set 1 vlan id off
322
323ipmitool -I dbus raw 0x06 0x40 // To the save settings
324```
325