其實現在一台簡易型的無線基地台,價格真的很便宜,Raspberry Pi的板子反而還比較貴,所以實在沒有拿Raspberry Pi來做無線AP的必要,純綷技術上的memo
# apt-get install hostapd udhcpd
# iw list|more 查看無線網路的性能清單
# vi /etc/network/interfaces
加入
iface wlan0 inet static
address 192.168.0.1
netmask 255.244.255.0
# vi /etc/udhcpd.conf
新增或修改幾行
interface wlan0
remaining yes
opt dns 168.95.1.1 這是要配給DHCP client的DNS
option subnet 255.255.255.0 這是要配給DHCP client的subnet
opt router 192.168.0.1 這是要配給DHCP client的default gateway(基本上是你無線網卡的IP),上面三行的設定需視你的網路環境而改變.
opt domain local
option lease 86400 這是要配給DHCP client的IP租期,視長短需要請自行修改
# vi /etc/default/udhcpd
將DHCP_ENABLE="no"改成#DHCP_ENABLE="no"
# vi /etc/hostapd/hostapd.conf
加入
interface=wlan0
driver=n180211
ssid=myssid
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=Pr0t3ct3d
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
# vi /etc/default/hostapd
加入
DAEMON_CONF="/etc/hostapd/hostapd.conf"
# vi /etc/sysctl.conf
加入或取消註解
net.ipv4.ip_forward=1
# iptables-save > /etc/iptables-rules
# vi /etc/iptables-rules
加入
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
# iptables-restore < /etc/iptables-rules
# update-rc.d hostapd enable
# update-rc.d udhcpd enable
# service hostapd start
# service udhcpd start
完成,可以用你的手機看看有沒有wifi的點了!!