TTEP.CN > 手机 >
Raspberry Pi无线路由器篇
Raspberry Pi无线路由器篇
RaspberryPi可以折腾的方法很多,我将会吧自己的折腾经验与大家分享。
作为无线路由器,需要提供dhcp的功能和无线ap的能力,我们分别通过isc-dhcp-server和hostapd这两个软件来实现,网卡间转发直接通过iptables定义nat规则来实现。
安装dhcp服务和ap热点服务
[python]
apt-get install isc-dhcp-server
apt-get install hostapd
修改/etc/network/interfaces

在/etc/dhcp/dhcpd.conf添加

修改/etc/hostapd/hostapd.conf

打开内核的网卡转发能力,将/etc/sysctl.conf的
[python]
net.ipv4.ip_forward=1
的注释去掉。
修改iptables的nat规则
[python]
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
将规则添加成为自动启动方式
[python]
iptables-save > /root/nat.rule
新建/etc/network/if-pre-up.d/iptables
[python]
#!/bin/bash
/sbin/iptables-restore < /root/nat.rule
或者直接在文件里写入规则语句
如果你的hostapd没有办法正常工作,应该是hostapd不支持你的网卡芯片,下载:https://github---/cnsworder/RTL8188-hostapd/archive/master.zip (2.29M)
在raspberrypi上直接编译就可以了(编译速度确实很慢的)
[python]
cd hostapd
make;make install
重新修改hostapd的配置文件就可以了。
看到了树梅派的热点

RaspberryPi可以折腾的方法很多,我将会吧自己的折腾经验与大家分享。
作为无线路由器,需要提供dhcp的功能和无线ap的能力,我们分别通过isc-dhcp-server和hostapd这两个软件来实现,网卡间转发直接通过iptables定义nat规则来实现。
安装dhcp服务和ap热点服务
[python]
apt-get install isc-dhcp-server
apt-get install hostapd
修改/etc/network/interfaces

在/etc/dhcp/dhcpd.conf添加

修改/etc/hostapd/hostapd.conf

打开内核的网卡转发能力,将/etc/sysctl.conf的
[python]
net.ipv4.ip_forward=1
的注释去掉。
修改iptables的nat规则
[python]
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
将规则添加成为自动启动方式
[python]
iptables-save > /root/nat.rule
新建/etc/network/if-pre-up.d/iptables
[python]
#!/bin/bash
/sbin/iptables-restore < /root/nat.rule
或者直接在文件里写入规则语句
如果你的hostapd没有办法正常工作,应该是hostapd不支持你的网卡芯片,下载:https://github---/cnsworder/RTL8188-hostapd/archive/master.zip (2.29M)
在raspberrypi上直接编译就可以了(编译速度确实很慢的)
[python]
cd hostapd
make;make install
重新修改hostapd的配置文件就可以了。
看到了树梅派的热点

- 最近发表
- 赞助商链接