{"id":455,"date":"2019-07-06T19:06:10","date_gmt":"2019-07-06T11:06:10","guid":{"rendered":"https:\/\/www.hncldz.com\/?p=455"},"modified":"2023-12-15T13:14:59","modified_gmt":"2023-12-15T05:14:59","slug":"%e6%a0%91%e8%8e%93%e6%b4%be3b%e9%85%8d%e7%bd%aewifi%e4%b8%ad%e7%bb%a7","status":"publish","type":"post","link":"https:\/\/www.hncldz.com\/?p=455","title":{"rendered":"\u6811\u8393\u6d3e3B\/4B\u914d\u7f6eWiFi\u4e2d\u7ee7"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\"><strong>\u76ee\u6807<\/strong><\/h4>\n\n\n\n<p>\u6700\u8fd1\u6811\u6885\u6d3e4B\u53d1\u5e03\uff0c\u76f8\u6bd4\u6811\u6885\u6d3e3B\u5728CPU\u3001\u5185\u5b58\u3001\u7f51\u5361\u3001USB\u7b49\u5404\u65b9\u9762\u5927\u5e45\u5347\u7ea7\uff0c\u53c8\u5524\u8d77\u4e86\u6211\u5bf9\u6811\u6885\u6d3e\u7684\u5174\u8da3\u3002\u6dd8\u5b9d\u4e0a\u5f88\u5feb\u5c31\u53ef\u4ee5\u4e70\u5230\u4e86\uff0c\u4e0d\u8fc7\u5728\u51c6\u5907\u4e0b\u5355\u7684\u65f6\u5019\uff0c\u6211\u95ee\u4e86\u81ea\u5df1\u4e00\u4e2a\u95ee\u9898\uff1a\u6211\u8981\u4e70\u6765\u5e72\u4ec0\u4e48\uff1f\u662f\u8981\u628a\u73a9\u4e24\u5929\u4e4b\u540e\u5c31\u8ba9\u5b83\u53d8\u6210\u201c\u5403\u7070\u6d3e\u201d\u5417\uff1f<\/p>\n\n\n\n<p>\u6700\u7ec8\uff0c\u6211\u89c9\u5f97\u7528\u6811\u6885\u6d3e\u505a\u4e00\u4e2awifi\u4e2d\u7ee7\u662f\u4e00\u4e2a\u6bd4\u8f83\u597d\u7684\u7528\u9014\u3002\u4e0d\u8fc7\uff0c\u505a\u4e00\u4e2awifi\u4e2d\u7ee7\uff0c3B\u7684\u6027\u80fd\u8db3\u77e3\uff0c\u4e8e\u662f\u6211\u627e\u51fa\u4e86\u6b63\u5728\u5403\u7070\u7684\u6811\u6885\u6d3e3B\uff0c\u6700\u7ec8\u4e5f\u5c31\u6709\u4e86\u8fd9\u7bc7\u6587\u7ae0\u3002<\/p>\n\n\n\n<p>2020-2-1\u5907\u6ce8\uff1a\u6b64\u6587\u540c\u6837\u9002\u7528\u4e8e\u6811\u8393\u6d3e4B<\/p>\n\n\n\n<p>\u4e0b\u9762\u8bb0\u5f55\u4e00\u4e0b\u5982\u4f55\u5c06\u4e00\u4e2a\u53ccWiFi\u7684\u6811\u8393\u6d3e\u53d8\u4e3a\u4e00\u4e2a\u8f6fAP\uff0c\u4ece\u800c\u53ef\u4ee5\u5c06WiFi\u7684\u4fe1\u53f7\u8fdb\u884c\u8ddd\u79bb\u5ef6\u5c55\uff0c\u540c\u65f6\u5b9e\u73b0\u5c06\u65e0\u7ebf\u8f6c\u6709\u7ebf\u3002\u539f\u7406\u7b80\u5355\u70b9\u8bf4\u5c31\u662f\u6811\u6885\u6d3e\u901a\u8fc7\u4e00\u4e2aUSB\u7f51\u5361\u63a5\u6536\u4e00\u4e2awifi\u4fe1\u53f7\uff0c\u7136\u540e\u901a\u8fc7NAT\u8f6c\u53d1\u5230\u81ea\u5e26\u7684\u65e0\u7ebf\u7f51\u5361\u4e0a\u5efa\u7acb\u7684wifi\u548c\u81ea\u5e26\u7684\u6709\u7ebf\u7f51\u5361\u4e0a\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h4_2\"><strong>\u51c6\u5907\u5de5\u4f5c<\/strong><\/h4>\n\n\n\n<p>\u51c6\u5907\u4e00\u4e2ausb\u65e0\u7ebf\u7f51\u5361\uff0c\u6211\u7528\u7684\u662f\u8fc5\u6377\u7684FW150US\uff0c\u5f62\u5982\u4e00\u4e2a\u65e0\u7ebf\u9f20\u6807\u63a5\u6536\u5668\uff0c\u5f88\u4fbf\u5b9c\u3002<\/p>\n\n\n\n<p>\u7ed9\u6811\u6885\u6d3e3B\u5237\u5199\u7cfb\u7edf\uff0c\u5177\u4f53\u8fc7\u7a0b\u4e0d\u8d58\u8ff0\uff0c\u6211\u7528\u7684\u662f\u76ee\u524d\u6700\u65b0\u7684\u5b98\u65b9\u7cfb\u7edf\uff0c\u955c\u50cf\u540d\u79f0\u4e3a2019-06-20-raspbian-buster.iso\u3002\u7b2c\u4e00\u6b21\u8fdb\u7cfb\u7edf\u65f6\u8bf7\u6b63\u786e\u9009\u62e9\u8bed\u8a00\u3001\u56fd\u5bb6\u3001\u65f6\u533a\u7b49\u7b49\u3002\u8bb0\u5f97\u539f\u6765\u7684\u7248\u672c\u9700\u8981\u624b\u52a8\u53bb\u8bbe\u7f6ewifi\u56fd\u522b\uff0c\u65b0\u7248\u4f3c\u4e4e\u4e0d\u5fc5\u4e86\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h4_9\"><strong>\u56fa\u5b9aWLAN\u63a5\u53e3\u540d\u79f0<\/strong><\/h4>\n\n\n\n<p>\u56e0\u4e3a\u4f7f\u7528\u4e86\u4e24\u4e2aWIFI\u9002\u914d\u5668\uff0c\u4e3a\u4e86\u9632\u6b62\u7cfb\u7edf\u5f00\u673a\u65f6\u968f\u673a\u5206\u914d\u54ea\u4e2a\u662fwlan0\uff0c\u54ea\u4e2a\u662fwlan1\uff0c\u56e0\u4e3a\u4e24\u4e2a\u9002\u914d\u5668\u4e0d\u4e00\u6837\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u8fd0\u884c\u5728\u4e0a\u9762\u7684\u914d\u7f6e\u6ca1\u529e\u6cd5\u751f\u6548\u3002\u56e0\u6b64\uff0c\u6211\u4eec\u5fc5\u987b\u8ba9\u7cfb\u7edf\u8bb0\u4f4fWIFI\u9002\u914d\u5668\u4f7f\u7528\u7684\u63a5\u53e3\u540d\u79f0\u3002\u672c\u4f8b\u4e2d\uff0cwlan0\u4e3a\u6811\u6885\u6d3e\u81ea\u5e26\u7684\u65e0\u7ebf\u7f51\u5361\uff0cwlan1\u4e3ausb\u65e0\u7ebf\u7f51\u5361\u3002<\/p>\n\n\n\n<p>\u7f16\u8f91\u65b0\u589e\u6587\u4ef6\/etc\/udev\/rules.d\/10-network.rules\uff0c\u5176\u4e2d\u7684\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SUBSYSTEM==\"net\", ACTION==\"add\", ATTR{address}==\"aa:bb:cc:dd:ee:ff\", NAME=\"wlan0\"\nSUBSYSTEM==\"net\", ACTION==\"add\", ATTR{address}==\"aa:bb:cc:dd:ee:ff\", NAME=\"wlan1\"<\/code><\/pre>\n\n\n\n<p>\u6ce8\u610f\u5176\u4e2d\u7684mac\u5730\u5740\uff0c\u8bbe\u7f6e\u4e3a\u4f60\u7684\u8bbe\u5907\u7684mac\u5730\u5740\u3002\u83b7\u5f97mac\u5730\u5740\uff0c\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4ip link<\/p>\n\n\n\n<p>\u91cd\u542f\u7cfb\u7edf\u540e\uff0c\u518d\u63d2\u5165\u8bbe\u5907\uff0c\u5c31\u4f1a\u7ed1\u5b9a\u63a5\u53e3\u540d\u79f0<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u7528wlan1\u8fde\u7f51<\/strong><\/h4>\n\n\n\n<p>\u672c\u4f8b\u4e2d\uff0c\u662f\u7528usb\u65e0\u7ebf\u7f51\u5361\u5373wlan1\u6765\u8054\u7f51\uff0c\u5148\u8bbe\u7f6e\u597dwlan1\u8981\u8fde\u63a5\u7684wifi\uff0c\u65b9\u4fbf\u4e0b\u9762\u5b89\u88c5\u8f6f\u4ef6\u5305\u548c\u6d4b\u8bd5\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h4_10\"><strong>\u56fa\u5b9aeth0\u3001wlan0\u7684IP<\/strong><\/h4>\n\n\n\n<p>\u7f16\u8f91\u6587\u4ef6\/etc\/dhcpcd.conf\uff0c  \u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> interface eth0\n static ip_address=192.168.3.1\/24\n interface wlan0\n static ip_address=192.168.4.1\/24\n nohook wpa_supplicant<\/code><\/pre>\n\n\n\n<p>\u73b0\u5728\u91cd\u542f<code>dhcpcd<\/code>\u5b88\u62a4\u8fdb\u7a0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl restart dhcpcd<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h4_11\"><strong>\u5b89\u88c5dnsmasq\u6765\u8bbe\u7f6eDHCP\u670d\u52a1<\/strong><\/h4>\n\n\n\n<p>\u5148\u6765\u8bf4\u660e\u4e00\u4e0b\u6211\u7684\u7f51\u6bb5\u8bbe\u7f6e\uff0c\u6709\u7ebf\u7f51\u7edc\u4f7f\u7528192.168.3.*\u8fd9\u4e2a\u7f51\u6bb5\uff0c\u800c\u65e0\u7ebfAP\u7aef\uff0c\u4f7f\u7528192.168.4.*\u7f51\u6bb5<\/p>\n\n\n\n<p>\u4f7f\u7528\u547d\u4ee4sudo apt-get install dnsmasq\u5b89\u88c5dnsmasq\uff0c\u7f16\u8f91\/etc\/dnsmasq.conf\uff0c\u6dfb\u52a0\u5982\u4e0b\u914d\u7f6e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> listen-address=127.0.0.1,192.168.3.1,192.168.4.1\n interface=eth0\n dhcp-range=192.168.3.50,192.168.3.150,12h\n interface=wlan0\n dhcp-range=192.168.4.50,192.168.4.150,12h<\/code><\/pre>\n\n\n\n<p>\u8fd0\u884c\u547d\u4ee4sudo systemctl reload dnsmasq\u6765\u542f\u7528<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h4_12\"><strong>\u5f00\u542f\u5305\u8f6c\u53d1\u3001NAT<\/strong><\/h4>\n\n\n\n<p>Linux\u7cfb\u7edf\u9ed8\u8ba4\u5173\u95ed\u4e86IP\u5305\u8f6c\u53d1\uff0c\u56e0\u6b64\u4e0d\u80fd\u505a\u8def\u7531\u5668\u3002\u6240\u4ee5\u9700\u8981\u5148\u6253\u5f00\u5305\u8f6c\u53d1<\/p>\n\n\n\n<p>\u7f16\u8f91\/etc\/sysctl.conf\uff0c\u53bb\u6389\u4ee5\u4e0b\u5c5e\u6027\u524d\u7684\u6ce8\u91ca:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>net.ipv4.ip_forward=1<\/code><\/pre>\n\n\n\n<p>\u8fd0\u884csudo sysctl -p\u6765\u542f\u7528<\/p>\n\n\n\n<p>\u4e4b\u540e\u8fd0\u884c<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo iptables -t nat -A POSTROUTING -o wlan1 -j MASQUERADE<\/code><\/pre>\n\n\n\n<p>\u6765\u542f\u7528wlan1\u7aef\u53e3\u7684NAT<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h4_13\"><strong>\u914d\u7f6e\u9632\u706b\u5899<\/strong><\/h4>\n\n\n\n<p>\u4e0a\u4e00\u6b65\u4e2d\uff0c\u6211\u4eec\u542f\u7528\u4e86\u4e00\u6761\u9632\u706b\u5899\u89c4\u5219\uff0c\u4f46\u662f\u9632\u706b\u5899\u89c4\u5219\u91cd\u542f\u540e\u5c31\u4e22\u5931\u4e86\uff0c\u4e3a\u4e86\u80fd\u591f\u89c4\u5219\u5f00\u673a\u81ea\u52a8\u52a0\u8f7d\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528iptables-persistent\u3002\u7528\u547d\u4ee4sudo apt-get install iptables-persistent\u6765\u5b89\u88c5\u8be5\u7ec4\u4ef6\uff0c\u6839\u636e\u5176\u63d0\u793a\u8fdb\u884c\u521d\u6b21\u8bbe\u7f6e\uff08\u4e00\u8def\u786e\u8ba4\uff09\u3002\u8be5\u7ec4\u4ef6\u9ed8\u8ba4\u4f1a\u5c06\u9632\u706b\u5899\u89c4\u5219\u4fdd\u5b58\u5230\/etc\/iptables\/rules.v4\u4e2d\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\u4fdd\u5b58\u548c\u8bfb\u5165\u89c4\u5219:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#\u4fdd\u5b58\u73b0\u6709\u89c4\u5219\n sudo service netfilter-persistent save\n #\u8bfb\u53d6\u5e76\u5e94\u7528\u5148\u6709\u89c4\u5219\n sudo service netfilter-persistent reload<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h4_14\"><strong>\u786e\u8ba4WIFI\u9002\u914d\u5668\u652f\u6301AP\u6a21\u5f0f<\/strong><\/h4>\n\n\n\n<p>\u4e0a\u9762\u8bf4\u8fc7\uff0c\u6211\u7528\u7684usb\u65e0\u7ebf\u7f51\u5361\u662f\u8fc5\u6377\u7684FW150US\uff0c\u7b2c\u4e00\u6b21\u914d\u7f6e\u65f6\uff0c\u6211\u8bd5\u56fe\u7528\u8fd9\u4e2ausb\u65e0\u7ebf\u7f51\u5361\u6765\u5f00\u542fAP\uff0c\u5931\u8d25\u4e4b\u540e\u53d1\u73b0\uff0c\u8fd9\u4e2a\u7f51\u5361\u7528\u5185\u6838\u81ea\u5e26\u7684\u9a71\u52a8\u65f6\u4e0d\u652f\u6301AP mode\u3002\u597d\u5728\u6811\u6885\u6d3e3B\u81ea\u5e26\u7684\u65e0\u7ebf\u7f51\u5361\u662f\u652f\u6301\u7684\u3002\u53ef\u4ee5\u4f7f\u7528\u547d\u4ee4iw list\u67e5\u770b\u7f51\u5361\u662f\u5426\u652f\u6301ap mode\uff0c\u5728\u547d\u4ee4\u8f93\u51fa\u91ccSupported interface modes\u4e0b\u67e5\u770b\u662f\u5426\u6709AP\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h4_17\"><strong>\u5b89\u88c5\u5e76\u5f00\u542fhostapd<\/strong><\/h4>\n\n\n\n<p>Linux\u542f\u7528WIFI\u70ed\u70b9\uff0c\u4f7f\u7528\u7684\u662fhostapd\u3002\u9996\u5148\uff0c\u7528\u547d\u4ee4sudo apt-get install hostapd\u5b89\u88c5\u5b83\uff0c\u7136\u540e\u589e\u52a0\u914d\u7f6e\u6587\u4ef6\/etc\/hostapd\/hostapd.conf\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> interface=wlan0\n driver=nl80211\n ssid=ssid\n hw_mode=g\n channel=13\n macaddr_acl=0\n auth_algs=1\n ignore_broadcast_ssid=0\n wpa=2\n wpa_passphrase=passwd\n wpa_key_mgmt=WPA-PSK\n wpa_pairwise=TKIP\n rsn_pairwise=CCMP<\/code><\/pre>\n\n\n\n<p>\u8bf7\u9700\u8981\u66f4\u6539\u5176\u4e2d\u7684ssid\u548cwpa_passphrase\u5c5e\u6027\uff0c\u5206\u522b\u4e3a\u65e0\u7ebfAP\u7684\u540d\u79f0\u548c\u5bc6\u7801\u3002<\/p>\n\n\n\n<p>\u4e4b\u540e\u8fd0\u884c\u547d\u4ee4sudo hostapd -d \/etc\/hostapd\/hostapd.conf\u6765\u89c2\u5bdf\u6d4b\u8bd5\uff0c\u6ca1\u6709\u9519\u8bef\u53ef\u4ee5\u8fde\u63a5\uff0c\u5c31OK\u4e86\u3002 CTRL\uff0bC\u540e\uff0c\u7f16\u8f91\/etc\/default\/hostapd\uff0c\u6539\u53d8DAEMON_CONF\u7684\u914d\u7f6e\u5982\u4e0b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>DAEMON_CONF=\"\/etc\/hostapd\/hostapd.conf\"<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u6b63\u5f0f\u542f\u52a8AP<\/strong><\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo systemctl unmask hostapd\n\nsudo systemctl enable hostapd\n\nsudo systemctl start hostapd<\/code><\/pre>\n\n\n\n<p> \u5173\u673a\u91cd\u542f\u4e00\u4e0b\uff0c\u770b\u770bAP\u662f\u5426\u80fd\u591f\u542f\u52a8\u8d77\u6765\u3002\u5982\u679c\u6b63\u5e38\u5c31OK\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6807 \u6700\u8fd1\u6811\u6885\u6d3e4B\u53d1\u5e03\uff0c\u76f8\u6bd4\u6811\u6885\u6d3e3B\u5728CPU\u3001\u5185\u5b58\u3001\u7f51\u5361\u3001USB\u7b49\u5404\u65b9\u9762\u5927\u5e45\u5347\u7ea7\uff0c\u53c8\u5524\u8d77\u4e86\u6211\u5bf9\u6811\u6885\u6d3e\u7684\u5174\u8da3 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[50,51,52],"class_list":["post-455","post","type-post","status-publish","format-standard","hentry","category-55","tag-50","tag-51","tag-3b"],"_links":{"self":[{"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/posts\/455","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=455"}],"version-history":[{"count":12,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/posts\/455\/revisions"}],"predecessor-version":[{"id":540,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=\/wp\/v2\/posts\/455\/revisions\/540"}],"wp:attachment":[{"href":"https:\/\/www.hncldz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=455"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=455"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hncldz.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=455"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}