樹莓派3B+ (PPOE+hostapd)變身無線路由器

替換樹莓派官方源爲阿里源

#/etc/apt/sources.list
deb http://mirrors.aliyun.com/raspbian/raspbian stretch main contrib non-free rpi
##****# Uncomment line below then 'apt-get update' to enable 'apt-get source'
deb-src http://mirrors.aliyun.com/raspbian/raspbian 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 end
interface wlan0
static ip_address=10.1.0.1/24
nohook wpa_supplicant
#configure dhcp server
sudo vi /etc/dnsmasq.conf
interface=wlan0
listen-address=10.1.0.1
server=114.114.114.114
dhcp-range=10.1.0.10,10.1.0.100,24h

#config hostapd
sudo vi /etc/hostapd/hostapd.conf
iinterface=wlan0
channel=7
hw_mode=g
wmm_enabled=1
#ieee80211n=1
#ht_capab=[HT40+][SHORT-GI-40][TX-STBC][RX-STBC2][DSSS_CK-40][LDPC]
macaddr_acl=0
ssid=Art
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_passphrase=Xmas200907
wpa_pairwise=TKIP
rsn_pairwise=CCMP

sudo vi /etc/defaut/hostapd #default configure location
DAEMON_CONF="/etc/hostapd/hostapd.conf"

#PPOE
sudo ppoeconf

#ip forward

sudo vi /etc/systctl.conf
net.ipv4.ip_forward=1

sysctl -p

#enable NAT
sudo iptables -t nat -I POSTROUTING -o ppp0 -s 10.1.0.0/24 -j MASQUERADE
sudo iptables-save > /etc/iptables/rules.v4
sudo /etc/init.d/netfilter-persistent restart

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章