@@ -23,30 +23,51 @@ Running DHCPv4 client in Linux Host
23
23
===================================
24
24
25
25
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
27
27
on Linux host.
28
28
29
29
To use QEMU for testing, follow the :ref: `networking_with_qemu ` guide.
30
30
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'
32
32
used to configure the DHCPv4 server:
33
33
34
34
.. code-block :: console
35
35
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
+ }
43
64
44
65
Use another terminal window to start up a DHCPv4 server on the Linux host,
45
66
using this conf file:
46
67
47
68
.. code-block :: console
48
69
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
50
71
51
72
Run Zephyr samples/net/dhcpv4_client application in QEMU:
52
73
@@ -62,12 +83,13 @@ are shown like this:
62
83
63
84
.. code-block :: console
64
85
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
71
93
72
94
To verify the Zephyr application client is running and has received
73
95
an ip address by typing:
@@ -81,8 +103,8 @@ FRDM_K64F
81
103
=========
82
104
83
105
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.
86
108
87
109
Connect ethernet cable from :ref: `Freedom-K64F board <frdm_k64f >` to Linux host
88
110
machine and check for new interfaces:
@@ -98,25 +120,46 @@ Add ip address and routing information to interface:
98
120
$ sudo ip addr add 192.0.2.2 dev eth1
99
121
$ sudo ip route add 192.0.2.0/24 dev eth1
100
122
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'
102
124
used to configure the DHCPv4 server:
103
125
104
126
.. code-block :: console
105
127
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
+ }
113
156
114
157
Use another terminal window to start up a DHCPv4 server on the Linux host,
115
158
using this conf file:
116
159
117
160
.. code-block :: console
118
161
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
120
163
121
164
Build Zephyr samples/net/dhcpv4_client application:
122
165
@@ -133,12 +176,13 @@ are shown like this:
133
176
.. code-block :: console
134
177
135
178
$ 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
142
186
143
187
To verify the Zephyr application client is running and has received
144
188
an ip address by typing:
0 commit comments