因為 Cubie Truck 內建有無線網路卡,之前有試著把 Raspberry Pi 做成無線 AP,也在網路上找了一下相關的資料。
參考網站:
Cubieboard 开箱和入门 | Name5566
如何使用樹莓派變成無線熱點 [Raspberry Pi become a WIFI(wireless) AP]
吉瓦小棧: 三月 2013
Cubieboard3做AP热点
【原创】让CubieBoard具备WIFI AP热点功能 – 其他Linux cubie.cc
底下的做法是不用做認證即可上網,比較不安全
安裝 hostapd
$ su –
# apt-get install hostapd [@more@]
建立設定檔
# vim /etc/hostapd/hostapd.conf
interface=wlan0
driver=nl80211
ssid=CubieTruck
channel=11
hw_mode=g
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
安裝 DHCP Server
# apt-get install isc-dhcp-server
設定由 wlan0 介面來發送 IP
# sed -i ‘s/INTERFACES=””/INTERFACES=”wlan0″/’ /etc/default/isc-dhcp-server
設定 DHCP Server
# grep -v ^# /etc/dhcp/dhcpd.conf | grep -v ^$
ddns-update-style none;
option domain-name “example.org”;
option domain-name-servers ns1.example.org, ns2.example.org;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;
subnet 172.16.0.0 netmask 255.255.255.0 {
range 172.16.0.1 172.16.0.10;
option domain-name-servers 168.95.1.1;
option domain-name-servers 8.8.8.8;
option routers 172.16.0.254;
}
設定無線網路卡網路組態
# vim /etc/network/interfaces
auto wlan0
iface wlan0 inet static
address 172.16.0.254
netmask 255.255.255.0
network 172.16.0.0
broadcast 172.16.0.255
重新啟動網路
# /etc/init.d/networking restart
重新啟動 DHCP Server
# /etc/init.d/isc-dhcp-server restart
設定防火牆
# vim /etc/firewall.wifiap
#!/bin/bash
IPTABLES=/sbin/iptables
$IPTABLES -F
$IPTABLES -F -t nat
$IPTABLES -X
$IPTABLES -P INPUT ACCEPT
$IPTABLES -P OUTPUT ACCEPT
$IPTABLES -P FORWARD ACCEPT
modprobe ip_conntrack
modprobe iptable_nat
modprobe ip_conntrack_ftp
modprobe ip_nat_ftp
echo 1 > /proc/sys/net/ipv4/ip_forward
$IPTABLES -t nat -A POSTROUTING -j MASQUERADE
執行防火牆規則
# sh /etc/firewall.wifiap
執行 hostapd 開啟熱點功能
# hostapd -B /etc/hostapd/hostapd.conf
Configuration file: /etc/hostapd/hostapd.conf
Failed to create interface mon.wlan0: -95 (Operation not supported)
Using interface wlan0 with hwaddr 02:1a:11:fe:c0:3d and ssid ‘CubieTruck’
設定開機時立即執行
# sed -i ‘/^exit 0/ish /etc/firewall.wifiap’ /etc/rc.local
# sed -i ‘/^exit 0/i/usr/sbin/hostapd -B /etc/hostapd/hostapd.conf’ /etc/rc.local
使用 Windows 7 來做測試
選擇 CubieTruck 無線網路