手把手教你使用 Raspberry
来源:互联网 发布:樱井知香番号大全 编辑:程序博客网 时间:2024/05/18 11:15
RPI Wireless-Access-Point
将Raspberry Pi3 作为无线路由接入点
Install the necessary software.
$ sudo apt-get install hostapd udhcpd
Configure DHCP
/etc/udhcpd.conf
$ sudo nano /etc/udhcpd.conf// 将文件修为为如下内容:start 192.168.42.2 # This is the range of IPs that the hostspot will give to client devices.end 192.168.42.20interface wlan0 # The device uDHCP listens on.remaining yesopt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use.opt subnet 255.255.255.0opt router 192.168.42.1 # The Pi's IP address on wlan0 which we will set up shortly.opt lease 864000 # 10 day DHCP lease time in seconds
Edit the file
/etc/default/udhcpd
and change the line:DHCPD_ENABLED="no"
to
#DHCPD_ENABLED="no"
Configure Network
allow-hotplug wlan0iface wlan0 inet staticaddress 192.168.42.1netmask 255.255.255.0
Change the lines (they probably won’t all be next to each other):
wpa-roam /etc/wpa_supplicant/wpa_supplicant.confiface default inet manual
to
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf#iface default inet dhcp
/etc/network/interfaces
like this:# interfaces(5) file used by ifup(8) and ifdown(8)# Please note that this file is written to be used with dhcpcd# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'# Include files from /etc/network/interfaces.d:source-directory /etc/network/interfaces.dauto loiface lo inet loopbackiface eth0 inet manualallow-hotplug wlan0iface wlan0 inet static address 192.168.52.1 netmask 255.255.255.0 gateway 192.168.52.1 network 192.168.52.0 broadcast 192.168.52.255 dns-nameservers 192.168.52.1 8.8.8.8 8.8.4.4#iface wlan0 inet manual# wpa-conf /etc/wpa_supplicantwpa_supplicant.conf#allow-hotplug wlan1#iface wlan1 inet manual# wpa-conf /etc/wpa_supplicant/wpa_supplicant.confup iptables-restore < /etc/iptables.ipv4.nat
Configure HostAPD. edit the file
/etc/hostapd/hostapd.conf
(create it if it doesn’t exist) and add the following lines:A secure network
interface=wlan0driver=nl80211ssid=My_APhw_mode=gchannel=6macaddr_acl=0auth_algs=1ignore_broadcast_ssid=0wpa=2wpa_passphrase=My_Passwordwpa_key_mgmt=WPA-PSK#wpa_pairwise=TKIP # You better do not use this weak encryption (only used by old client devices)rsn_pairwise=CCMP
A open network
interface=wlan0ssid=My_APhw_mode=gchannel=6auth_algs=1wmm_enabled=0
If Raspberry Pi 3 add this parameters:
ieee80211n=1 # 802.11n supportwmm_enabled=1 # QoS supportht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
Edit the file
/etc/default/hostapd
and change the line:#DAEMON_CONF=""
to
DAEMON_CONF="/etc/hostapd/hostapd.conf"
Configure NAT (Network Address Translation). NAT is a technique that allows several devices to use a single connection to the internet. Linux supports NAT using Netfilter (also known as iptables) and is fairly easy to set up. First, enable IP forwarding in the kernel:
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
To set this up automatically on boot, edit the file /etc/sysctl.conf and add the following line to the bottom of the file:
net.ipv4.ip_forward=1
To enable NAT in the kernel, run the following commands:
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADEsudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPTsudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT
These instructions don’t give a good solution for rerouting https and for URLs referring to a page inside a domain, like www.nu.nl/38274.htm. The user will see a 404 error. Your Pi is now NAT-ing. To make this permanent so you don’t have to run the commands after each reboot, run the following command:
sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"
Now edit the file /etc/network/interfaces and add the following line to the bottom of the file:
up iptables-restore < /etc/iptables.ipv4.nat
Fire it Up!
sudo service hostapd startsudo service udhcpd start
Your Pi should now be hosting a wireless hotspot. To get the hotspot to start on boot, run these additional commands:
sudo update-rc.d hostapd enablesudo update-rc.d udhcpd enable
本文参考RPI-Wireless-Hotspot,在其基础之上网络配置部分稍作调整,在Raspberry Debian 8 上运行没有问题!
- 手把手教你使用 Raspberry
- 手把手教你使用 Raspberry
- 手把手教你使用 Raspberry
- 手把手教你使用VSS
- 手把手教你使用Git
- 手把手教你使用Git
- 手把手教你使用Git
- 手把手教你使用Git
- 手把手教你使用Git
- 手把手教你使用Git
- 手把手教你使用git
- 手把手教你使用Git
- 手把手教你使用Git
- 手把手教你使用Git
- 手把手教你使用GiT
- 手把手教你使用Git
- 手把手教你使用Git
- 手把手教你使用Git
- 查找——冒泡排序
- 查找——冒泡排序
- 看图和步骤教你把dwg转换成pdf格式
- 查找——冒泡排序
- 注意事项,不定期更新
- 手把手教你使用 Raspberry
- 设计模式(10) 门面/外观模式(简单入门 结构模式)
- Thinkphp按照汉字的首字拼音排序
- openfire实现多点登陆
- 淘淘商城系列(六)类目选择和富文本编辑器的使用
- 使用EventBus通讯不成功
- linux 常用命令
- 解决在Android中给Button设置Padding无效的问题
- OC语言学习14-JSON数据解析