本文共 1504 字,大约阅读时间需要 5 分钟。
替换树莓派官方源为阿里源
#/etc/apt/sources.list
deb stretch main contrib non-free rpi##****# Uncomment line below then 'apt-get update' to enable 'apt-get source'deb-src stretch main contrib non-free rpi安装所需要的软件
#Install program
sudo apt-get install dnsmasq hostapd pppoeconf iptables-persistent配置树莓派wlan0的ip地址(注意树莓派的ip已经由/etc/dhcpcd.conf管理,需要在此文件中修改相应信息)
sudo vi /etc/dhcpcd.conf
#add following information at endinterface wlan0static ip_address=10.1.0.1/24nohook wpa_supplicant#configure dhcp serversudo vi /etc/dnsmasq.confinterface=wlan0listen-address=10.1.0.1server=114.114.114.114dhcp-range=10.1.0.10,10.1.0.100,24h#config hostapd
sudo vi /etc/hostapd/hostapd.confinterface=wlan0channel=7hw_mode=gwmm_enabled=1#ieee80211n=1#ht_capab=[HT40+][SHORT-GI-40][TX-STBC][RX-STBC2][DSSS_CK-40][LDPC]macaddr_acl=0ssid=Artwpa=2wpa_key_mgmt=WPA-PSKwpa_passphrase=Xmas200907wpa_pairwise=TKIPrsn_pairwise=CCMPsudo vi /etc/defaut/hostapd #default configure location
DAEMON_CONF="/etc/hostapd/hostapd.conf"通过
hostapd -d /etc/hostapd/hostapd.conf来调试hostapd#PPOE
sudo ppoeconf#ip forward
sudo vi /etc/sysctl.conf
net.ipv4.ip_forward=1sysctl -p
#enable NAT
sudo iptables -t nat -I POSTROUTING -o ppp0 -s 10.1.0.0/24 -j MASQUERADEsudo iptables-save > /etc/iptables/rules.v4sudo /etc/init.d/netfilter-persistent restart如果出现
iptables v1.8.1 (nf_tables): Chain 'MASQUERADE' does not exist执行update-alternatives --config iptables选择 iptables-legacy 即可修正这个错误转载于:https://blog.51cto.com/26081/2353390