本文為大家介紹raspberry wifi(raspberry pi 4b openwrt),下面和小編一起看看詳細(xì)內(nèi)容吧。
樹莓派無線路由器篇
raspberrypi的折騰方式有很多種,我把我的折騰經(jīng)驗(yàn)分享給大家。
作為無線路由器,需要提供dhcp的功能和無線ap的能力。我們分別使用軟件isc-dhcp-server和hostapd來實(shí)現(xiàn)。網(wǎng)卡之間的轉(zhuǎn)發(fā)直接通過在iptables中定義nat規(guī)則來實(shí)現(xiàn)。
安裝dhcp服務(wù)和ap熱點(diǎn)服務(wù)
[python]
apt-get 安裝isc-dhcp-server
apt 安裝hostapd
修改/etc/network/interfaces
在/etc/dhcp/dhcpd.conf中添加
修改/etc/hostapd/hostapd.conf
開啟內(nèi)核網(wǎng)卡的轉(zhuǎn)發(fā)能力,設(shè)置/etc/sysctl.conf
[python]
net.ipv4.ip_forward=1
評(píng)論已刪除。
修改iptables的nat規(guī)則
[python]
iptables -t nat -a postrouting -o eth0 -j masquerade
添加規(guī)則作為自動(dòng)啟動(dòng)方法
[python]
iptables-save /root/nat.rule
新建/etc/network/if-pre-up.d/iptables
[python]
#!/bin/慶典
/sbin/iptables-恢復(fù)
好了,raspberry wifi(raspberry pi 4b openwrt)的介紹到這里就結(jié)束了,想知道更多相關(guān)資料可以收藏我們的網(wǎng)站。