DHCP: Analysis of 2 implementation methods for dynamically acquiring IP on the Development Board _c language

Source: Internet
Author: User

Dhcp
The Dynamic Host Setup protocol, which is a network protocol of a LAN, uses UDP protocol to work for two main purposes: Configuration Protocol, DHCP.
1. Automatically assign IP addresses to internal networks or network service providers
2. Give the user to the internal network administrator as a means of central management of all computers.

method One: Dhclient
1. Download
https://www.isc.org/software/dhcp/
2. Decompression
TAR-ZXVF dhcp-3.1.3.tar.gz
3. Configure
cddhcp-3.1.3
./configure
The work.linux-2.2 folder is generated after success.
4. Compile
Make "Cc=/opt/hisi-linux/x86-arm/gcc-3.4.3-uclibc-0.9.28/usr/bin/arm-hismall-linux-gcc-static"
You can make it in the Work.linux-2.2/client directory or in the dhcp-3.1.3 directory,
5. Copy
Build Dhclient in Work.linux-2.2\client compilation.
Copy configuration filedhcp-3.1.3/client/dhclient.confAnd/dhcp-3.1.3/client/scripts/linuxTo the/sbin/directory of the developer board, and the Linux file is renamed toDhclient-script, and modify the first line of the file#!/bin/bashFor#!/bin/sh, after saving, modify permissionschmod +x/sbin/dhclient-script
6. Create a table of contents
mkdir-p/var/state/dhcp
Create a state directory under the/var directory, and then create a DHCP directory under the State directory.
7. Run
Dhclient RA0
Results:

Copy Code code as follows:

Internetsystems Consortium DHCP Client V3.1.3
copyright2004-2009 Internet Systems Consortium.
Allrights reserved.
Forinfo, please visit https://www.isc.org/software/dhcp/
Listeningon lpf/ra0/7c:dd:90:25:9f:a9
Sendingon lpf/ra0/7c:dd:90:25:9f:a9
Sendingon Socket/fallback
Dhcpdiscoveron ra0 to 255.255.255.255 port interval 6
Dhcpdiscoveron ra0 to 255.255.255.255 port interval 12
Dhcpdiscoveron ra0 to 255.255.255.255 port interval 14
Dhcpofferfrom 192.168.1.1
Dhcprequeston RA0 to 255.255.255.255 port 67
Dhcpackfrom 192.168.1.1
Bound to 192.168.1.31-renewal in 282261 seconds.

Method Two, Udhcpc
Udhcpc is a very small DHCP client for embedded systems, the initials micro-DHCP-client (ΜDHCPC).
1.udhcpc-i eth0
udhcpc Just get an IP, we need to put \busybox-1.1.2\examples\ UDHCP script Simple.script renamed to Default.script, placed on the Development Board/usr/share/dhcpc/directory, in order to write the acquired IP to the specified network card.
2.ifconfig

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.