Skip to content

Commit 28ed03a

Browse files
rlubosaescolar
authored andcommitted
samples: net: dhcpv4_client: Replace example DHCP server with kea
Currently used DHCP server in the sample, dhcpd, is no longer maintained and reached EOL. Therefore, update the sample's readme file with a sample configuration for its successor, kea. Signed-off-by: Robert Lubos <[email protected]>
1 parent 4f1ee4b commit 28ed03a

File tree

1 file changed

+77
-33
lines changed

1 file changed

+77
-33
lines changed

samples/net/dhcpv4_client/README.rst

Lines changed: 77 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,51 @@ Running DHCPv4 client in Linux Host
2323
===================================
2424

2525
These are instructions for how to use this sample application using
26-
QEMU on a Linux host to negotiate IP address from DHCPv4 server running
26+
QEMU on a Linux host to negotiate IP address from DHCPv4 server (kea) running
2727
on Linux host.
2828

2929
To use QEMU for testing, follow the :ref:`networking_with_qemu` guide.
3030

31-
Here's a sample server configuration file '/etc/dhcp/dhcpd.conf'
31+
Here's a sample server configuration file '/etc/kea/kea-dhcp4.conf'
3232
used to configure the DHCPv4 server:
3333

3434
.. code-block:: console
3535
36-
log-facility local7;
37-
default-lease-time 600;
38-
max-lease-time 7200;
39-
40-
subnet 192.0.2.0 netmask 255.255.255.0 {
41-
range 192.0.2.10 192.0.2.100;
42-
}
36+
{
37+
"Dhcp4": {
38+
"interfaces-config": {
39+
"interfaces": [ "tap0" ],
40+
"dhcp-socket-type": "raw"
41+
},
42+
43+
"valid-lifetime": 7200,
44+
45+
"subnet4": [
46+
{
47+
"id": 1,
48+
"subnet": "192.0.2.0/24",
49+
"pools": [ { "pool": "192.0.2.10 - 192.0.2.100" } ],
50+
"option-data": [
51+
{
52+
"name": "routers",
53+
"data": "192.0.2.2"
54+
},
55+
{
56+
"name": "domain-name-servers",
57+
"data": "8.8.8.8"
58+
}
59+
]
60+
}
61+
]
62+
}
63+
}
4364
4465
Use another terminal window to start up a DHCPv4 server on the Linux host,
4566
using this conf file:
4667

4768
.. code-block:: console
4869
49-
$ sudo dhcpd -d -4 -cf /etc/dhcp/dhcpd.conf -lf /var/lib/dhcp/dhcpd.leases tap0
70+
$ sudo kea-dhcp4 -c /etc/kea/kea-dhcp4.conf
5071
5172
Run Zephyr samples/net/dhcpv4_client application in QEMU:
5273

@@ -62,12 +83,13 @@ are shown like this:
6283

6384
.. code-block:: console
6485
65-
[dhcpv4] [INF] main: In main
66-
[dhcpv4] [INF] main_thread: Run dhcpv4 client
67-
[dhcpv4] [INF] handler: Your address: 192.0.2.10
68-
[dhcpv4] [INF] handler: Lease time: 600
69-
[dhcpv4] [INF] handler: Subnet: 255.255.255.0
70-
[dhcpv4] [INF] handler: Router: 0.0.0.0
86+
[00:00:00.000,000] <inf> net_dhcpv4_client_sample: Run dhcpv4 client
87+
[00:00:00.000,000] <inf> net_dhcpv4_client_sample: Start on slip: index=1
88+
[00:00:07.080,000] <inf> net_dhcpv4: Received: 192.0.2.10
89+
[00:00:07.080,000] <inf> net_dhcpv4_client_sample: Address[1]: 192.0.2.10
90+
[00:00:07.080,000] <inf> net_dhcpv4_client_sample: Subnet[1]: 255.255.255.0
91+
[00:00:07.080,000] <inf> net_dhcpv4_client_sample: Router[1]: 192.0.2.2
92+
[00:00:07.080,000] <inf> net_dhcpv4_client_sample: Lease time[1]: 7200 seconds
7193
7294
To verify the Zephyr application client is running and has received
7395
an ip address by typing:
@@ -81,8 +103,8 @@ FRDM_K64F
81103
=========
82104

83105
These are instructions for how to use this sample application running on
84-
:ref:`frdm_k64f` board to negotiate IP address from DHCPv4 server running on
85-
Linux host.
106+
:ref:`frdm_k64f` board to negotiate IP address from DHCPv4 server (kea) running
107+
on Linux host.
86108

87109
Connect ethernet cable from :ref:`Freedom-K64F board <frdm_k64f>` to Linux host
88110
machine and check for new interfaces:
@@ -98,25 +120,46 @@ Add ip address and routing information to interface:
98120
$ sudo ip addr add 192.0.2.2 dev eth1
99121
$ sudo ip route add 192.0.2.0/24 dev eth1
100122
101-
Here's a sample server configuration file '/etc/dhcpd/dhcp.conf'
123+
Here's a sample server configuration file '/etc/kea/kea-dhcp4.conf'
102124
used to configure the DHCPv4 server:
103125

104126
.. code-block:: console
105127
106-
log-facility local7;
107-
default-lease-time 600;
108-
max-lease-time 7200;
109-
110-
subnet 192.0.2.0 netmask 255.255.255.0 {
111-
range 192.0.2.10 192.0.2.100;
112-
}
128+
{
129+
"Dhcp4": {
130+
"interfaces-config": {
131+
"interfaces": [ "eth1" ],
132+
"dhcp-socket-type": "raw"
133+
},
134+
135+
"valid-lifetime": 7200,
136+
137+
"subnet4": [
138+
{
139+
"id": 1,
140+
"subnet": "192.0.2.0/24",
141+
"pools": [ { "pool": "192.0.2.10 - 192.0.2.100" } ],
142+
"option-data": [
143+
{
144+
"name": "routers",
145+
"data": "192.0.2.2"
146+
},
147+
{
148+
"name": "domain-name-servers",
149+
"data": "8.8.8.8"
150+
}
151+
]
152+
}
153+
]
154+
}
155+
}
113156
114157
Use another terminal window to start up a DHCPv4 server on the Linux host,
115158
using this conf file:
116159

117160
.. code-block:: console
118161
119-
$ sudo dhcpd -d -4 -cf /etc/dhcp/dhcpd.conf -lf /var/lib/dhcp/dhcpd.leases eth1
162+
$ sudo kea-dhcp4 -c /etc/kea/kea-dhcp4.conf
120163
121164
Build Zephyr samples/net/dhcpv4_client application:
122165

@@ -133,12 +176,13 @@ are shown like this:
133176
.. code-block:: console
134177
135178
$ sudo screen /dev/ttyACM0 115200
136-
[dhcpv4] [INF] main: In main
137-
[dhcpv4] [INF] main_thread: Run dhcpv4 client
138-
[dhcpv4] [INF] handler: Your address: 192.0.2.10
139-
[dhcpv4] [INF] handler: Lease time: 600
140-
[dhcpv4] [INF] handler: Subnet: 255.255.255.0
141-
[dhcpv4] [INF] handler: Router: 0.0.0.0
179+
[00:00:00.000,000] <inf> net_dhcpv4_client_sample: Run dhcpv4 client
180+
[00:00:00.000,000] <inf> net_dhcpv4_client_sample: Start on ethernet: index=1
181+
[00:00:07.080,000] <inf> net_dhcpv4: Received: 192.0.2.10
182+
[00:00:07.080,000] <inf> net_dhcpv4_client_sample: Address[1]: 192.0.2.10
183+
[00:00:07.080,000] <inf> net_dhcpv4_client_sample: Subnet[1]: 255.255.255.0
184+
[00:00:07.080,000] <inf> net_dhcpv4_client_sample: Router[1]: 192.0.2.2
185+
[00:00:07.080,000] <inf> net_dhcpv4_client_sample: Lease time[1]: 7200 seconds
142186
143187
To verify the Zephyr application client is running and has received
144188
an ip address by typing:

0 commit comments

Comments
 (0)