赞
踩
sudo apt-get updatesudo apt-get install dnsmasq hostapd udhcpd
sudo vi /etc/dhcpcd.confinterface wlan0static ip_address=192.168.88.1/24
# 表示使用localhostauto lo iface lo inet loopback# wlan1 自动获取IPauto wlan1iface wlan1 inet dhcppre-up wpa_supplicant -Dwext -i wlan1 -c /etc/wpa_supplicant/wpa_supplicant.conf -B# wlan0 为静态IPauto wlan0allow-hotplug wlan0iface wlan0 inet staticaddress 192.168.88.1netmask 255.255.255.0
sudo service dhcpcd restartsudo reboot
start 192.168.88.100 #配置网段end 192.168.88.150interface wlan0 # The device uDHCP listens on.remaining yesopt dns 192.168.1.1 8.8.8.8opt subnet 255.255.255.0opt router 192.168.88.1 # 无线lan网段opt lease 864000 # 租期10天
sudo vi /etc/hostapd/hostapd.conf
interface=wlan0driver=nl80211ssid=H-Pihw_mode=gchannel=6wmm_enabled=1macaddr_acl=0auth_algs=1ignore_broadcast_ssid=0wpa=2wpa_passphrase=abc12345wpa_key_mgmt=WPA-PSKrsn_pairwise=CCMP
DAEMON_CONF="/etc/hostapd/hostapd.conf"
sudo update-rc.d hostapd enable
sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.bak
interface=wlan0bind-interfacesserver=218.2.2.2server=114.114.114.114server=8.8.8.8domain-neededbogus-privdhcp-range=192.168.88.2,192.168.88.254,12h
sudo vi /etc/sysctl.conf# Uncomment the next line toenable packet forwarding for IPv4net.ipv4.ip_forward=1
sudo iptables -Fsudo iptables -Xsudo iptables -t nat -APOSTROUTING -o wlan1 -j MASQUERADEsudo iptables -A FORWARD -i wlan1 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPTsudo iptables -A FORWARD -i wlan0 -o wlan1 -j ACCEPT
sudo sh -c "iptables-save> /etc/iptables.ipv4.nat"
up iptables-restore < /etc/iptables.ipv4.nat
#!/bin/bash/sbin/iptables-restore < /etc/iptables.ipv4.nat
sudo chmod 755 /etc/network/if-pre-up.d/iptables
sudo vi /lib/dhcpcd/dhcpcd-hooks/70-ipv4-natsudo iptables-restore < /etc/iptables.ipv4.nat
sudo service hostapd startsudo service dnsmasq startsudo reboot
sudo vi /etc/wpa_supplicant/wpa_supplicant.conf
network={ ssid="SSID" psk="wifi_password"}
pi@raspberrypi:~ $ sudo wpa_cli reconfigureSelected interface 'wlan0'OK
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。