Busybox built-in tftpd, FTPD, telnetd, udhcpd, udhcpc Configuration

Source: Internet
Author: User

Busybox built-in tftpd, FTPD, telnetd, udhcpd, udhcpc Configuration

Tftpd and ftpd can be managed by inetd, and telnetd can also be managed by inetd theoretically. However, I have not called the development board yet and can only run telnetd independently.
1. tftpd
Configuration steps:
# Mkdir/tftp_ftp_dir // create the root directory of the TFTP Server
# Vi/etc/inetd. conf // configure the inetd. conf file, use inetd to manage tftpd, and add the following line:
69 dgram UDP Nowait root tftpd-C/tftp_ftp_dir
# Inetd // start inetd
In this way, tftpd runs as a daemon.
Note: The tftpd running in this way does not see the running of the tftpd process in PS.

check the configuration result:
# netstat-phosphatase
active Internet connections (servers and established)
proto Recv-Q send-Q local address foreign address State PID/program name
UDP 0 0.0.0.0: 69 0.0.0.0: * 789/inetd
active Unix domain sockets (servers and established)
proto refcnt flags type state I-node PID/program name path

The next step is to test it on the client.
I tried the following three testing methods:
A) On a Linux PC, run the TFTP Command directly to connect to the Development Board. Can be connected, but get file will prompt error code 0: malformed packet. Some people on the Internet say that the default tftp on Ubuntu 8.10 cannot work due to packet protocol problems, but I use the fedora 9 system. I captured the packet and read it, the data packet replied by the TFTP server has a TFTP code field. There is no solution yet.
B) copy the file test under the tftpd root directory of the Development Board (if there is no test file, you can manually create one) to the PC, and enter the following command on the Development Board:
# Busybox TFTP-l test-r test-P 192.168.0.22
The file is successfully received on the PC. The file content is correct.
C) on Windows PC, use 3com tftp software as the TFTP client to test whether the file is successfully downloaded from the Development Board.

2. ftpd
Configuration steps:
# Mkdir/tftp_ftp_dir // create the root directory of the FTP server
# Vi/etc/inetd. conf // configure the inetd. conf file, use inetd to manage tftpd, and add the following line:
21 stream tcp Nowait root ftpd-W/tftp_ftp_dir
# Inetd // start inetd
In this way, ftpd runs as a daemon.
Note: The ftpd process running in this mode cannot be seen in PS.

Check the configuration result:
# Netstat-phosphatase
Active Internet connections (servers and established)
PROTO Recv-Q send-Q local address foreign address State PID/program name
TCP 0 0 0.0.0.0: 21 0.0.0.0: * Listen 789/inetd
Active Unix domain sockets (servers and established)
PROTO refcnt flags type state I-node PID/program name path

The next step is to test it on the client.
Direct FTP data on a Linux PC:
[Root @ fedora9 ~] # Ftp 192.168.0.1
You can log on through the anonymous user Anonymous
Ftp> LCD
Ftp> put test // upload the test file to the ftpd root directory of the Development Board.
Ftp> get test
The downloaded file is successfully tested.

3. telnetd
Telnetd configuration is actually very simple. kernel options:
Device Drivers --->
Character Devices
[*] Unix98 Pty support
[*] Legacy (BSD) Pty support
(256) Maximum number
Busybox options:
# Busybox-> networking utilities-> telnetd
# Busybox-> networking utilities-> support standalone telnetd (not inetd only)
It should be enough. But after I complete the configuration, start telnetd on the Development Board:
Telnetd-L/bin/login
Then, run the ps command to check whether the process telnetd exists, and run the netstat-CLP command to check that port 23 has been listened on.
On the client Telnet Development Board, there is always a message indicating "Connection closed by foreign host". When the client is connected via Telnet, the telnetd process on the Development Board automatically exits. Packet Capture found that the TCP three-way handshake connection has been established. After debugging for one day, I finally realized that it was not attached to the devpts file system.
You need to mount it on the Development Board. Enter the following command on the Development Board:
# Mount-T devpts/dev/PTS

However, if you use inetd to manage telnetd, the message "Connection closed by foreign host" still appears. The reason is unclear.

4. udhcpd
Refer to examples in busybox to configure udhcpd. conf. Configure the address pool (START, end, option subnet), default gateway (OPT router), and DNS (option DNS. Then execute:
# Udhcpd-fs/etc/udhcpd. conf
Then you can start the DHCP server. During execution, the udhcpd may prompt that there is no udhcpd. Release file. You only need to create it in the corresponding folder. Run the following two commands:
# Mkdir-P/var/lib/MISC/
# Touch/var/lib/MISC/udhcpd. Leases

Note: To enable the DHCP service, make sure that the corresponding network port is in the up status and the IP address has been configured. Otherwise, an error is returned when udhcpd-fs/etc/udhcpd. conf is executed.

5. udhcpc
See simple in example/udhcp/of busybox. script script, rename it to default. script (it doesn't matter if you don't change it), mainly because the default directory file in busybox is/usr/share/udhcpc/default. script
Note: Make sure that the default. script can be executed. I used to debug this problem for a long time.
You can view the content of default. Script:
#! /Bin/sh <br/> # udhcpc script edited by Tim Riker <Tim@Rikers.org> <br/> resolv_conf = "/etc/resolv. conf "<br/> [-n" $1 "] | {echo" error: shocould be called from udhcpc "; Exit 1 ;} <br/> netmask = "" <br/> [-n "$ subnet"] & netmask = "netmask $ subnet" <br/> broadcast = "broadcast +" <br/> [-n "$ broadcast"] & Broadcast = "broadcast $ broadcast" <br/> case "$1" in <br/> deconfig) <br/> echo "setting IP address 0.0.0.0 on $ interface" <br/> ifconfig $ interface 0.0.0.0 <br/>;< br/> renew | bound) <br/> echo "setting IP address $ IP on $ interface" <br/> ifconfig $ interface $ IP $ netmask $ broadcast <br/> If [-n "$ Router" ]; then <br/> echo "deleting routers" <br/> while route del default GW 0.0.0.0 Dev $ interface; DO <br/>: <br/> done <br/> metric = 0 <br/> for I in $ router; DO <br/> echo "adding router $ I" <br/> route add default GW $ I Dev $ interface metric $ (metric ++ )) <br/> done <br/> fi <br/> echo "recreating $ resolv_conf" <br/> echo-N> $ resolv_conf-$ <br/> [-n "$ domain"] & Echo "Search $ domain" >$ resolv_conf-$ <br/> for I in $ DNS; DO <br/> echo "adding DNS server $ I" <br/> echo "nameserver $ I" >>$ resolv_conf-$ <br/> done <br/> mv $ resolv_conf-$ resolv_conf <br/> ;; <br/> esac <br/> exit 0

All udhcpc operations are in this script.

During the test, you can prepare a DHCP server and run the following command on the Development Board:
# Udhcpc-I eth0-S/usr/share/udhcpc/Default. Script

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.