Raspberry Pi無線路由器篇

來源:互聯網
上載者:User

RaspberryPi可以折騰的方法很多,我將會吧自己的折騰經驗與大家分享。

作為無線路由器,需要提供dhcp的功能和無線ap的能力,我們分別通過isc-dhcp-server和hostapd這兩個軟體來實現,網卡間轉寄直接通過iptables定義nat規則來實現。

安裝dhcp服務和ap熱點服務

apt-get install isc-dhcp-serverapt-get install hostapd

修改/etc/network/interfaces

在/etc/dhcp/dhcpd.conf添加

修改/etc/hostapd/hostapd.conf

開啟核心的網卡轉寄能力,將/etc/sysctl.conf的

net.ipv4.ip_forward=1

的注釋去掉。

修改iptables的nat規則

iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

將規則添加成為自動啟動方式

iptables-save > /root/nat.rule

建立/etc/network/if-pre-up.d/iptables

#!/bin/bash/sbin/iptables-restore < /root/nat.rule 

或者直接在檔案裡寫入規則語句

如果你的hostapd沒有辦法正常工作,應該是hostapd不支援你的網卡晶片,下載:https://github.com/cnsworder/RTL8188-hostapd/archive/master.zip

在raspberrypi上直接編譯就可以了(編譯速度確實很慢的)

cd hostapdmake;make install

重新修改hostapd的設定檔就可以了。

看到了樹梅派的熱點

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.