用树莓派3做无线路由器

1、sudo apt-get install hostapd dnsmasq
2、在/etc/dnsmasq.conf末加入
interface=wlan0
dhcp-range=10.0.0.2,10.0.0.5,255.255.255.0,12h

3、新建/etc/hostapd/hostapd.conf,加入
interface=wlan0
hw_mode=g
channel=10
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
wpa_passphrase=xuefiang
ssid=xuefliang

4、修改/etc/sysctl.conf,使得
net.ipv4.ip_forward=1

5、将下面脚本加入到/etc/rc.local的exit 0前:

ifconfig wlan0 down
ifconfig wlan0 10.0.0.1 netmask 255.255.255.0 up
iwconfig wlan0 power off
service dnsmasq restart
hostapd -B /etc/hostapd/hostapd.conf & > /dev/null 2>&1
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

6、重启树莓派

评论

此博客中的热门博文

V2ray websocket(ws)+tls+nginx分流

Rstudio 使用代理