Embedded topic: Dual-nic WiFi build up Nat Internet

Source: Internet
Author: User

Condition: Dual NICs on the Development Board, one of which is USB WiFi, provide the WiFi routing function. Another network port can be connected to the Internet.

Objective: To connect a common PC or mobile phone to this Wi-Fi route and connect to the Internet.

 

1. WiFi AP

USB WiFi part: Do not use multiple words, this uses RealTek 8188 UC version, this WiFi official software comes with the corresponding driver application software. The package rtl8188c_8192c_usb_linux_v4.0.2_9000.20130911.zip contains three parts: Driver, hostapd, and wpa_supplicant. There is also wireless_tools, which can be ignored.

Hostapd is a software used to convert a USB WiFi into an AP route. USB WiFi generally has two modes: STA (tion) mode and a (ccess) P (oint) mode. Its hostapd is customized based on hostapd and can support its own USB WiFi software. Please feel free to use it.

Hostapd compilation process:

Edit. config, and add
Cc = arm-None-Linux-gnueabi-gcc
Destdir =/opt/x210/hostapd
Cflags + =-I $ (destdir)/include
Libs + =-L $ (destdir)/lib
Where,
CC cross compiler
Location of make install after destdir Compilation
Add libnl and OpenSSL to cflags and libs.

Make
Make install.

A configuration file is required when hostapd is supported. Modify it on the rtl_hostapd_2g.conf configuration provided by hostapd.
Hostapd-B rtl_hostapd_2g.conf

 

##### hostapd configuration file ##############################################interface=wlan1ctrl_interface=/var/run/hostapdssid=rtwapchannel=8#auth_algs=1#wep_default_key=0#wep_key0="12345"#wep_key1=9797979797wpa=2wpa_passphrase=87654321wpa_psk_file=/opt/x210/hostapd8188/hostapd.wpa_psk#bridge=br0##### Wi-Fi Protected Setup (WPS) ##############################################eap_server=1# WPS state# 0 = WPS disabled (default)# 1 = WPS enabled, not configured# 2 = WPS enabled, configured#wps_state=2uuid=12345678-9abc-def0-1234-56789abcdef0# Device Name# User-friendly description of device; up to 32 octets encoded in UTF-8device_name=RTL8192CU# Manufacturer# The manufacturer of the device (up to 64 ASCII characters)manufacturer=Realtek# Model Name# Model of the device (up to 32 ASCII characters)model_name=RTW_SOFTAP# Model Number# Additional device description (up to 32 ASCII characters)model_number=WLAN_CU# Serial Number# Serial number of the device (up to 32 characters)serial_number=12345# Primary Device Type# Used format: <categ>-<OUI>-<subcateg># categ = Category as an integer value# OUI = OUI and type octet as a 4-octet hex-encoded value; 0050F204 for#       default WPS OUI# subcateg = OUI-specific Sub Category as an integer value# Examples:#   1-0050F204-1 (Computer / PC)#   1-0050F204-2 (Computer / Server)#   5-0050F204-1 (Storage / NAS)#   6-0050F204-1 (Network Infrastructure / AP)device_type=6-0050F204-1# OS Version# 4-octet operating system version number (hex string)os_version=01020300# Config Methods# List of the supported configuration methodsconfig_methods=label display push_button keypad##### default configuration #######################################driver=rtl871xdrvbeacon_int=100hw_mode=gieee80211n=1wme_enabled=1ht_capab=[SHORT-GI-20][SHORT-GI-40][HT40+]wpa_key_mgmt=WPA-PSKwpa_pairwise=CCMPmax_num_sta=8wpa_group_rekey=86400

 

2. Nat Internet access

Nat is a technical feature supported by the Linux kernel. Therefore, you must add Nat support when compiling the kernel. The general principle is to allow forwarding and directly transfer data from one network port to another. Use the iptables command and the NAT option to perform operations. Of course, if the kernel does not support NAT, you do not have an iptables program.

(1) Compile the kernel

Full Nat support

(2) Compile iptables

The iptables package may not be available on your development board. You should compile one by yourself.

Please use v1.4.15./configure -- prefix =/opt/x210/iptables/-- Host = arm-None-Linux-gnueabimake make install

(3) Configure forwarding

echo 1 > /proc/sys/net/ipv4/ip_forwardiptables -t nat -A POSTROUTING -o wlan0  -j MASQUERADE

It's almost time, brother.

Related Article

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.