Design of wireless router based on embedded Linux--bridged Adapter Network Bridge mode __linux

Source: Internet
Author: User

Now the embedded device networking, there are two main modes: Ethernet RJ-45 interface directly plugged into the Internet network; 3g/4g module dial-up Internet access. With the continuous popularization of wireless terminal equipment, mobile phone plate and other wireless devices to the network demand is increasing. This article mainly introduces the design of wireless router based on embedded Linux, and accesses the network in a bridge-connected way. This method is suitable for devices that do not need dialing, that is, a direct cable can be connected to the network. The design of this dialing method based on 3G/4G will be described in the next article.

The common network connection way, the blog http://www.cnblogs.com/york-hust/archive/2012/03/29/2422911.html has a better introduction.

The following figure is a schematic diagram of my embedded Linux device hardware:


Because the use of bridging the way, that is, embedded devices can not dial their own, and can not route themselves. In other words, insert the embedded device of the network cable, directly plugged into the computer can access the Internet. The main design is to turn the wired network into a wireless LAN. The WiFi module here communicates with embedded Linux via a USB bus.

Kernel configuration:

When the kernel is configured, the 802.1D Ethernet Bridging and IEEE 802.11 for Host AP (PRISM2/2.5/3 and wep/tkip/ccmp) need to be selected to enable the kernel to support bridging while requiring WiFi to support AP functionality.

WiFi-driven porting :

WiFi-driven porting is still relatively simple, download the source of cross compilation can be. I am using rtl8188c, directly compiled into a module 8192cu.ko here need to pay more attention to, should be in the compilation module is required to specify the Linux kernel code path, when your kernel network configuration changes, your driver needs to recompile, Otherwise, there may be some memory overflow problems.

HOSTAPD Transplant:

HOSTAPD is the Host Access Point Daemon, which enables the wireless network card to switch to master mode, which simulates the AP (usually considered a router) function, which is what we call the soft AP (Soft AP). Its porting and configuration can refer to the http://www.cnblogs.com/zhuwenger/archive/2011/03/11/1980294.html


to start the embedded device setting:

1. Load Driver

Insmod 8192cu.ko

2. Start WiFi network interface

Ifconfig wlan0 up

3. Create a virtual network bridge

Brctl ADDBR Br0

4. The Wired network interface and the wireless network interface are added to the virtual Network Bridge

Brctl addif br0 eth0
Brctl addif br0 Wlan0

5. Clear the Wired and wireless network Network settings (since all data is sent through the virtual network interface)

Ifconfig eth0 0.0.0.0
Ifconfig Wlan0 0.0.0.0

6. Start Virtual network interface

Ifconfig br0 up

7. Configure virtual network port IP address and subnet mask

Ifconfig br0 192.168.2.2 netmask 255.255.255.0

8. Configure the default gateway (important)

Route add default GW 192.168.2.254

9. Enable WiFi access to AP function

./HOSTAPD Hostapd.conf-b

Here are a few points to note:

A. 7th above, when setting IP and subnet masks, you need to be in the same network segment as the IP of your router (router a above). The default gateway also needs to be set like Router A. Because the network is connected by bridging, the device attached to the BR0 will be recognized as an actual device in the router. This means that other devices in router A also have access to the devices in the br0. In this way, the devices connected to WiFi, their IP is actually assigned by router A, so here we can not set DHCP to dynamically allocate IP for WiFi

B. In the./HOSTAPD hostapd.conf-b command-B refers to running in the background. Some of the WiFi parameters are set in hostapd.conf, such as the WiFi name Ssid,wifi channel. My hostapd.conf configuration file is as follows:

##### HOSTAPD configuration file ############################################## interface=wlan0 ctrl_interface=/var/ RUN/HOSTAPD ssid=licaibiao_debug channel=6 wpa=2 wpa_passphrase=87654321 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=2 UUID=12345678-9ABC-DEF0-1234-56789ABCDEF0 # Device Name # User-frie ndly description of device; Up to octets encoded in UTF-8 DEVICE_NAME=RTL8192CU # manufacturer The manufacturer of the device aracters) Manufacturer=realtek # model Name # Model of the device (up to + ASCII characters) Model_name=rtw_softap # Mo Del number # Additional device description (up to ASCII characters) MODEL_NUMBER=WLAN_CU # serial number # serial numb Er of the device (up to 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 Infrast RUCTURE/AP) Device_type=6-0050f204-1 # OS version # 4-octet operating system version number (hex string) os_version=010 20300 # Config Methods # List of the supported configuration Methods config_methods=label display Push_button Keypad #
### default configuration ####################################### driver=rtl871xdrv beacon_int=100 hw_mode=g Ieee80211n=1 wme_enabled=1 ht_capab=[short-gi-20][short-gi-40][ht40+] Wpa_key_mgmt=wpa-psk Wpa_pairwise=CCMP max_
 Num_sta=8 wpa_group_rekey=86400


This article refers to:

USB WiFi porting

Build Network Bridge and script writing under Linux

Quick understanding of VirtualBox Four network connection modes




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.