日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

手把手教你使用 Raspberry - Wireless-Access-Point

發布時間:2024/5/8 编程问答 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 手把手教你使用 Raspberry - Wireless-Access-Point 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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.20 interface wlan0 # The device uDHCP listens on. remaining yes opt dns 8.8.8.8 4.2.2.2 # The DNS servers client devices will use. opt subnet 255.255.255.0 opt 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 wlan0 iface wlan0 inet static address 192.168.42.1 netmask 255.255.255.0
    • Change the lines (they probably won’t all be next to each other):

      wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface 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 lo iface lo inet loopbackiface eth0 inet manualallow-hotplug wlan0 iface wlan0 inet staticaddress 192.168.52.1netmask 255.255.255.0gateway 192.168.52.1network 192.168.52.0broadcast 192.168.52.255dns-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=wlan0 driver=nl80211 ssid=My_AP hw_mode=g channel=6 macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 wpa_passphrase=My_Password wpa_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=wlan0 ssid=My_AP hw_mode=g channel=6 auth_algs=1 wmm_enabled=0

    If Raspberry Pi 3 add this parameters:

    ieee80211n=1 # 802.11n support wmm_enabled=1 # QoS support ht_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 MASQUERADE sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT sudo 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 start sudo 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 enable sudo update-rc.d udhcpd enable

本文參考RPI-Wireless-Hotspot,在其基礎之上網絡配置部分稍作調整,在Raspberry Debian 8 上運行沒有問題!

總結

以上是生活随笔為你收集整理的手把手教你使用 Raspberry - Wireless-Access-Point的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。