Raspberry Pi 2无线路由器配置

使用环境:
* Raspberry Pi2 板子
* EP-N8508GS 无线网卡

使用软件
* hostapd
* udhcpd


1. 软件安装
sudo apt-get install hostapd udhcpd

官方hostapd无法兼容EP-N8508GS 无线网卡

wget http://www.daveconroy.com/wp3/wp-content/uploads/2013/07/hostapd.zip
unzip hostapd.zip 
sudo mv /usr/sbin/hostapd /usr/sbin/hostapd.bak
sudo mv hostapd /usr/sbin/hostapd.edimax 
sudo ln -sf /usr/sbin/hostapd.edimax /usr/sbin/hostapd 
sudo chown root.root /usr/sbin/hostapd 
sudo chmod 755 /usr/sbin/hostapd
2. 修改配置文件
2.1 修改hostapd
  • hostapd配置文件/etc/hostapd/hostapd.conf
interface=wlan0
ssid=MyNAT
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
  • 配置hostapd启动设置 /etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"
2.2 启动ip转发
  • 修改/etc/sysctl.conf
net.ipv4.ip_forward=1
  • 启用设置
sysctl -p
2.3 修改网络配置,对无线网卡wlan0
allow-hotplug wlan0
iface wlan0 inet static
    address 10.10.10.1
    netmask 255.255.255.0
2.4 修改udhcpd配置
  • 修改/etc/udhcpd.conf
start 10.10.10.2
end 10.10.10.20
interface wlan0
remaining yes
opt dns 8.8.8.8
opt subnet 255.255.255.0
opt router 10.10.10.1 
opt lease 864000
  • 修改服务配置/etc/default/udhcpd
#DHCPD_ENABLED="no"
2.5 修改防火墙
iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE
iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
3 启动服务
systemctl restart networking
systemctl restart hostapd
systemctl restart udhcpd
4 桥接配置

如果只是让有线网络转换为无线网络,那么修改配置为桥接方式建立热点

4.1 修改网络配置/etc/network/interfaces
auto lo
iface lo inet loopback
iface eth0 inet dhcp

auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
4.2 配置hostapd
  • 配置/etc/hostapd/hostapd.conf
interface=wlan0
bridge=br0
ssid=MyNAT2
channel=1
wmm_enabled=0
wpa=1
wpa_passphrase=12345678
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
auth_algs=1
macaddr_acl=0
  • 配置/etc/default/hostapd
DAEMON_CONF="/etc/hostapd/hostapd.conf"

引用资料
http://wangye.org/blog/archives/845/
http://blog.csdn.net/xukai871105/article/details/42497097
http://blog.itpub.net/29901741/viewspace-1294741/

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值