树莓派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
interface=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"

通过
hostapd -d /etc/hostapd/hostapd.conf来调试hostapd

#PPOE
sudo ppoeconf

#ip forward

sudo vi /etc/sysctl.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

如果出现
iptables v1.8.1 (nf_tables): Chain 'MASQUERADE' does not exist
执行
update-alternatives --config iptables
选择 iptables-legacy 即可修正这个错误

转载于:https://blog.51cto.com/26081/2353390

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值