TCC8900 Development Board for Wi-Fi Tethering + DHCP servers

Source: Internet
Author: User

Tethering technology has been widely used on mobile platforms. It can use mobile devices as an access point, and other devices can use Wi-Fi, connect to the mobile device using USB or Bluetooth.

Recently, network devices have been debugged on the TCC8900 Development Board of Telechips. You need to implement simple Tethering in Linux and share the network connection with other devices in Wi-Fi Ad-hoc mode. On the Development Board, a wired network adapter (eth1), a wireless network adapter (eth0), eth1 is connected to the Internet, and eth0 is shared as an AP to another PC with a wireless network adapter, this allows the PC to connect to the Internet through the Development Board. (The intranet IP address is 192.168.0 .*)

After analysis, we need to implement the following simple functions:
1. Wi-Fi Master or Ad-hoc mode configuration
2. NAT
3. DHCP server

Wi-Fi Mode settings
The Development Board provides the AR6102, an SDIO interface for Wi-Fi. From the hardware description, This Wi-Fi only supports Ad-hoc point-to-point mode, but does not support AP, therefore, use iwconfig to set it to the Ad-hoc mode.

1 iwconfig eth0 mode ad-hoc
2 iwconfig eth0 enc s:12345
3 iwconfig eth0 essid "tcc8900"
4 ifconfig eth0 up
5 ifconfig eth0 192.168.0.1

NAT implementation using iptables
Iptables can implement address translation, firewall, port filtering, and other functions. Here we only use the most basic address translation, so that the PC can access the Internet.

1 iptables -t nat -A POSTROUTING -o eth1 -s 192.168.0.0/24 -j MASQUERADE
2 echo "1" > /proc/sys/net/ipv4/ip_forward

Build a DHCP service using udhcpd
You need to create a new configuration file. The default value is/etc/udhcpd. conf, and a lease (lease) record file is required. The default value is/etc/udhcpd. leases, you can use the dumpleases command to view the lease of connected clients.

1 touch /etc/udhcpd.leases
2 udhcpd -S /etc/udhcpd.conf

Provides an example of udhcpd. conf.

01 # Sample udhcpd configuration file (/etc/udhcpd.conf)
02 # The start and end of the IP lease block
03 start            192.168.0.2
04 end              192.168.0.100
05   
06 # The interface that udhcpd will use
07 interface        eth0              #default: eth0
08   
09 # The maximim number of leases (includes addressesd reserved
10 # by OFFER's, DECLINE's, and ARP conficts
11 max_leases       20                #default: 254
12   
13 # If remaining is true (default), udhcpd will store the time
14 # remaining for each lease in the udhcpd leases file. This is
15 # for embedded systems that cannot keep time between reboots.
16 # If you set remaining to no, the absolute time that the lease
17 # expires at will be stored in the dhcpd.leases file.
18 remaining        yes               #default: yes
19   
20 # The time period at which udhcpd will write out a dhcpd.leases
21 # file. If this is 0, udhcpd will never automatically write a
22 # lease file. (specified in seconds)
23 auto_time        7200              #default: 7200 (2 hours)
24   
25 # The amount of time that an IP will be reserved (leased) for if a
26 # DHCP decline message is received (seconds).
27 decline_time     3600              #default: 3600 (1 hour)
28   
29 # The amount of time that an IP will be reserved (leased) for if an
30 # ARP conflct occurs. (seconds)
31 conflict_time    3600              #default: 3600 (1 hour)
32   
33 # How long an offered address is reserved (leased) in seconds
34 offer_time       60                #default: 60 (1 minute)
35   
36 # If a lease to be given is below this value, the full lease time is
37 # instead used (seconds).
38 min_lease        60                #defult: 60
39   
40 # The location of the leases file
41 lease_file       /etc/udhcpd.leases
42   
43 # The remainer of options are DHCP options and can be specifed with the
44 # keyword 'opt' or 'option'. If an option can take multiple items, such
45 # as the dns option, they can be listed on the same line, or multiple
46 # lines. The only option with a default is 'lease'.
47   
48 #Examples
49 opt        dns        8.8.8.8 8.8.8.4
50 option     subnet     255.255.255.0
51 opt        router     192.168.0.1

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.