CoCoDeng 发表于 2014-1-7 11:14:06

pcDuino+3G上网+AP

2013 年底,中国发布了 4G 牌照。什么是 4G 呢,4G 是集3G与 WLAN 于一体,并能够传输高质量视频图像,它的图像传输质量与高清晰度电视不相上下。 4G 系统能够以 100Mbps 的速度下载,比目前的拨号上网快 2000 倍,上传的速度也能达到 20Mbps ,并能够满足几乎所有用户对于无线服务的要求。虽然我现在没有这样一个 4G wifi 。但是我可以利用我手上的 pcDuino 手动实现这个设备。
一:配置内核支持nat
配置内核支持nat:
#cd ../kernel/build/sun4i_defconfig-linux/
#make CROSS_COMPILE=arm-linux-gnueabi- ARCH=armmenuconfig
Networking support—>
Networkingoptions—>
Network packetfiltering framework (Netfilter)—>
Core NetfilterConfiguration—>
<*>Netfilter LOG over NFNETLINK interface
<*>Netfilter connection tracking support
<*>Netfilter Xtables support (required for ip_tables)
IP: NetfilterConfiguration—>
如下图:

然后重新make,烧内核就完成了配置内核
二:配置AP
(1)下载工具软件

$apt-get update

$apt-get install isc-dhcp-server

(2)下载官网驱动源码

ftp://58.211.24.153/cn/wlan/RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip

(3)下载编译驱动需要内核头文件

$apt-get installpcduino-linux-headers-3.4.29+

$cd /usr/src/linux-headers-3.4.29+/arch

$cp armarmv7l-rf

$reboot

(4)删除原有的8188cu.ko

$rm/lib/modules/3.4.29+/kernel/drivers/net/wireless/rtl8192cu/8192cu.ko

$rm/lib/modules/3.4.29+/kernel/drivers/net/wireless/8192cu.ko

(5)编译安装驱动

$unzipRTL8188C_8192C_USB_linux_v4.0.2_9000.20130911.zip

$cdRTL8188C_8192C_USB_linux_v4.0.2_9000.20130911

$chmod +x install.sh

$sudo ./install.sh

(6)安装结束

(7)hostapd

驱动里面自带的hostapd是没有做成系统服务的,需要找到开源的系统服务。

$git clone https://github.com/jenssegers/RTL8188-hostapd

$cd RTL8188-hostapd/hostapd

$sudo make install

安装8188的hostapd

$cd RTL8188C_8192C_USB_linux_v4.0.2_9000.20130911/wpa_supplicant_hostapd

$tar xvfwpa_supplicant_hostapd-0.8_rtw_r7475.20130812.tar.gz

$sudo make install

配置hostapd

$vi /etc/hostapd/hostapd.conf

# Basic configuration

interface=wlan3   #根据你自己的接点

ssid=MyWifi

channel=1

#bridge=br0

# WPA and WPA2 configuration

macaddr_acl=0

auth_algs=1

ignore_broadcast_ssid=0

wpa=3

wpa_passphrase=12345678

wpa_key_mgmt=WPA-PSK

wpa_pairwise=TKIP

rsn_pairwise=CCMP

# Hardware configuration

driver=rtl871xdrv

ieee80211n=1

hw_mode=g

device_name=RTL8192CU

manufacturer=Realtek

保存

$service hostapd restart

(8)配置AP固定ip

$vi /etc/network/interfaces

auto wlan3

iface wlan3 inet static

       address192.168.3.1

       netmask 255.255.255.0

保存

$service networking restart

(9)配置dhcp

$vi /etc/dhcp/dhcpd.conf   #在最后面加

subnet 192.168.3.0 netmask 255.255.255.0{

range 192.168.3.2 192.168.3.200;

optionrouters 192.168.3.1;

optiondomain-name-servers8.8.8.8;

}

保存

$service isc-dhcp-server restart

(10)设置开机启动

hostapd启动后dhcpd才能启动,dhcpd关闭hostapd才关闭

$update-rc.d hostapd defaults 80 20

$update-rc.d isc-dhcp-server defaults 9010
如下图:



三:配置3G
(1)安装模式切换工具

$apt-get install usb-modeswitch

(2)安装拨号软件

$apt-get install wvdial

(3)配置软件

$leafpad /etc/wvdial.conf



Init1 = ATZ

Init2 = ATQ0 V1 E1 S0=0 &C1 &D2

Modem Type = Analog Modem

Baud = 9600

New PPPD = yes

Modem = /dev/ttyUSB0

ISDN = 0

Phone =*99#

Password = uninet

Username = uninet

保存

启动拨号:$wvdial
如下图:

四:内核转发

$echo 1 >/proc/sys/net/ipv4/ip_forward

$sudo iptables -t nat -A POSTROUTING -oppp0 -j MASQUERADE

电脑连该AP,能ping通

如下图:

页: [1]
查看完整版本: pcDuino+3G上网+AP