{"id":2906,"date":"2012-11-02T16:08:12","date_gmt":"2012-11-02T08:08:12","guid":{"rendered":"http:\/\/blog.dword1511.info\/?p=2906"},"modified":"2014-07-02T13:18:59","modified_gmt":"2014-07-02T05:18:59","slug":"%e8%ae%a9%e6%97%a0%e7%ba%bf%e7%bd%91%e5%8d%a1%e5%90%8c%e6%97%b6%e5%b7%a5%e4%bd%9c%e5%9c%a8-ap-%e5%92%8c-sta-%e6%a8%a1%e5%bc%8f","status":"publish","type":"post","link":"http:\/\/blog.dword1511.info\/?p=2906","title":{"rendered":"\u8ba9\u65e0\u7ebf\u7f51\u5361\u540c\u65f6\u5de5\u4f5c\u5728 AP \u548c STA \u6a21\u5f0f"},"content":{"rendered":"<p><strong>\u8fd9\u4e2a\u5e16\u5b50\u91cc\u7684\u65b9\u6cd5\u6709\u70b9\u8fc7\u65f6\u4e86\uff0c\u4e0d\u63a8\u8350\u7ee7\u7eed\u4f7f\u7528\u3002<\/strong><\/p>\n<p>\u6709\u7684\u65f6\u5019\u4f1a\u78b0\u5230\u8fd9\u4e48\u4e00\u79cd\u60c5\u51b5\uff0c\u5e26\u7740\u7535\u8111\u548c\u624b\u673a\u51fa\u53bb\u8e6d\u7f51\uff0c\u65e0\u5948\u53ea\u6709\u4e00\u4e2a\u8d26\u53f7\uff0c\u624b\u673a\u4e0a\u4e86\u7535\u8111\u5c31\u6ca1\u5f97\u7528\u4e86\uff0c\u7535\u8111\u7528\u4e86\u624b\u673a\u5c31\u4e0a\u4e0d\u4e86\u7f51\u3002\u5982\u679c\u80fd\u7528\u7535\u8111\u8fde\u63a5 Wifi \u7136\u540e\u518d\u5f00\u70ed\u70b9\u7ed9\u624b\u673a\u7528\u8be5\u591a\u597d\u3002\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u6bcf\u53f0\u7b14\u8bb0\u672c\u91cc\u9762\u53ea\u6709\u4e00\u5f20\u65e0\u7ebf\u7f51\u5361\uff0c\u6309\u7167\u5e38\u89c4\u7684\u601d\u8def\u8981\u4e00\u8fb9\u4f5c\u4e3a STA \u8fde\u63a5\u5728\u522b\u7684\u70ed\u70b9\u4e0a\uff0c\u4e00\u8fb9\u53c8\u8981\u505a AP \u7ed9\u624b\u673a\u7528\u7684\u8bdd\u4f3c\u4e4e\u5c31\u975e\u5f97\u518d\u4e70\u4e00\u5f20 USB \u7684\u65e0\u7ebf\u7f51\u5361\u4e86\u3002\u4e0d\u8fc7\u73b0\u5728\u6709\u4e00\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8ba9\u4e00\u5f20\u65e0\u7ebf\u7f51\u5361\u540c\u65f6\u5904\u4e8e STA \u548c AP \u7684\u72b6\u6001\uff0c\u4e00\u8fb9\u4f5c\u4e3a\u5ba2\u6237\u7aef\u8fde\u5728\u522b\u7684 AP \u4e0a\uff0c\u4e00\u8fb9\u53c8\u81ea\u5df1\u4f5c\u4e3a AP \u8ba9\u522b\u7684\u5ba2\u6237\u7aef\u6765\u8fde\u63a5\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u8fd9\u79cd\u7279\u6b8a\u7684\u201c\u4e00\u5361\u4e24\u7528\u201d\u7684\u72b6\u6001\u9700\u8981 WDS \u7684\u652f\u6301\u3002WDS \u662f\u4e00\u4e2a\u590d\u6742\u7684\u4e1c\u897f\uff0c\u73b0\u5728\u53ea\u8bb2\u7279\u5b9a\u60c5\u51b5\u4e0b\u7684\u5e94\u7528\u3002\u4e00\u822c\u6765\u8bb2\uff0c\u91c7\u7528 ath9k \u9a71\u52a8\u7684\u65e0\u7ebf\u7f51\u5361\u90fd\u662f\u652f\u6301 WDS \u7684\uff08\u5176\u5b83\u57fa\u4e8e mac80211 \u7684\u9a71\u52a8\u4e0d\u8be6\uff0c\u4e0d\u8fc7\u503c\u5f97\u4e00\u8bd5\uff09\u3002\u53e6\u5916\uff0c\u4e3a\u4e86\u80fd\u4f7f\u7528 WDS \uff0c\u8fd8\u8981\u6c42 hostapd \u7684\u7248\u672c\u5728 0.7.x \u4ee5\u4e0a\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u5c0f\u811a\u672c\uff0c\u5b83\u5c06\u5728 wlan0 \u4e0a\u542f\u52a8\u4e00\u4e2a AP \uff0c\u540c\u65f6\u751f\u6210\u4e00\u4e2a\u65b0\u7684\u63a5\u53e3 wds0 \uff0c\u53ef\u4f9b NetworkManager \u76f4\u63a5\u4f5c\u4e3a STA \u4f7f\u7528\u3002<\/p>\n<pre class=\"brush: bash; title: \u4ee3\u7801; notranslate\" title=\"\u4ee3\u7801\">\r\n#!\/bin\/sh\r\nWIFI=wlan0 # NOTE 1\r\nPHY=phy0 # NOTE 2\r\nWAN=wds0 # NOTE 3\r\n\r\n# Extra NAT Module\r\nmodprobe nf_nat_pptp\r\nmodprobe nf_nat_ftp\r\n# NOTE 4\r\n\r\n# Config Wireless\r\nifconfig $WIFI up\r\nifconfig $WIFI 172.16.1.1\/24\r\nifconfig $WIFI mtu 1500\r\n\r\n# Configure dnsmasq\r\ncat &gt; \/etc\/dnsmasq.conf &lt;&lt; EOF\r\ndhcp-range=172.16.1.100,172.16.1.150,255.255.255.0,24h\r\nport=0\r\ndhcp-option=option:dns-server,8.8.8.8,8.8.4.4\r\ninterface=$WIFI\r\nEOF\r\n# NOTE 5\r\n\r\n# DHCP server\r\nservice dnsmasq stop\r\nservice dnsmasq start\r\n\r\n# AP and WDS STA\r\nhostapd -B .\/hostapd-wds.conf\r\niw phy $PHY interface add $WAN type wds\r\nifconfig $WAN hw ether b4:82:fe:54:c8:3e # NOTE 6\r\nifconfig $WAN up\r\n\r\n# Enable IPv4 Forwarding\r\necho &quot;1&quot;  &gt; \/proc\/sys\/net\/ipv4\/ip_forward\r\niptables -P FORWARD ACCEPT\r\n\r\n# NAT with iptables\r\niptables -t nat -A POSTROUTING -o $WAN -s 172.16.1.1\/24 -j MASQUERADE\r\n<\/pre>\n<p>NOTES:<\/p>\n<ol>\n<li>wlan0 \u662f\u65e0\u7ebf\u7f51\u5361\u9ed8\u8ba4\u7684\u63a5\u53e3\u540d\u79f0\u3002\u4f7f\u7528\u65f6\u8bf7\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8bbe\u5b9a\u3002\u5bf9\u4e8e\u4f7f\u7528\u57fa\u4e8e mac80211 \u67b6\u6784\u9a71\u52a8\u7684\u7f51\u5361\uff0c\u5176\u63a5\u53e3\u540d\u4e00\u822c\u662f wlanx \uff0c\u7cfb\u7edf\u4e2d\u7684\u7b2c\u4e00\u5f20\u7f51\u5361\u4e00\u822c\u662f wlan0 \u3002\u7a0d\u540e\u8fd9\u4e2a\u63a5\u53e3\u4f1a\u88ab\u4f5c\u4e3a AP \u4f7f\u7528\uff1b<\/li>\n<li>\u8fd9\u662f\u5bf9\u5e94\u7684\u65e0\u7ebf\u7f51\u5361\u7684 PHY \u7684\u540d\u79f0\uff0c\u4e00\u822c\u4e3a phy0 \uff0c\u53ef\u4ee5\u8fd9\u6837\u627e\u51fa\uff1a\u5148 lspci \u627e\u51fa\u65e0\u7ebf\u7f51\u5361\u7684 PCI \u5730\u5740\uff0c\u7136\u540e ls \/sys\/bus\/pci\/devices\/<em>[\u5bf9\u5e94\u7684<strong>\u5b8c\u6574<\/strong> PCI \u5730\u5740]<\/em>\/ieee80211 \u5373\u53ef\u627e\u51fa\uff1b<\/li>\n<li>\u671f\u671b\u7684 WDS STA \u63a5\u53e3\u540d\u79f0\uff0c\u5b8c\u5168\u4f9d\u4e2a\u4eba\u559c\u597d\u586b\u5199\uff0c\u4e0d\u8981\u548c\u5df2\u6709\u7684\u63a5\u53e3\u51b2\u7a81\u5373\u53ef\uff1b<\/li>\n<li>\u52a0\u8f7d\u8fd9\u4e9b\u989d\u5916\u7684 module \u662f\u4e3a\u4e86\u4fdd\u8bc1\u5728 NAT \u540e\u9762\u7684 PPTP \u5ba2\u6237\u7aef\u548c FTP \u670d\u52a1\u5668\u80fd\u6b63\u5e38\u5de5\u4f5c\uff1b<\/li>\n<li>dnsmasq \u7684\u914d\u7f6e\u8bf7\u53c2\u8003\u00a0<a href=\"http:\/\/www.thekelleys.org.uk\/dnsmasq\/docs\/dnsmasq.conf.example\" target=\"_blank\">http:\/\/www.thekelleys.org.uk\/dnsmasq\/docs\/dnsmasq.conf.example<\/a>\u00a0\uff0c\u672c\u4f8b\u4e2d dnsmasq \u53ea\u505a DHCP \u670d\u52a1\u5668\uff0cIP \u5730\u5740\u8303\u56f4 172.16.1.100 &#8211; 172.16.1.150 \uff0c\u79df\u671f 24 \u5c0f\u65f6\uff0cDNS \u670d\u52a1\u5668\u9ed8\u8ba4\u4e3a 8.8.8.8 \u548c 8.8.4.4 \uff1b<\/li>\n<li>\u8fd9\u91cc\u7684 MAC \u5730\u5740\u4e5f\u662f\u6309\u7167\u4e2a\u4eba\u559c\u597d\u8bbe\u5b9a\u7684\uff0c\u4e0d\u8fc7\u4e0d\u8981\u548c\u7cfb\u7edf\u5df2\u6709\u7684\u4efb\u4f55\u7f51\u5361\u5730\u5740\u76f8\u540c\uff08\u5305\u62ec\u65e0\u7ebf\u7f51\u5361\u7684 AP \u63a5\u53e3\uff09\u3002<\/li>\n<\/ol>\n<p>\u6709\u5173\u7684 hostapd-wds.conf \u7684\u5185\u5bb9\u5982\u4e0b\uff0c\u8bf7\u653e\u7f6e\u5728\u8be5\u811a\u672c\u7684\u5de5\u4f5c\u76ee\u5f55\u4e0b\uff1a<\/p>\n<pre class=\"brush: bash; title: \u4ee3\u7801; notranslate\" title=\"\u4ee3\u7801\">auth_algs=1\r\nbeacon_int=300\r\nchannel=6 # NOTE 1\r\ncountry_code=CN\r\nctrl_interface_group=adm\r\nctrl_interface=\/var\/run\/hostapd\r\ndriver=nl80211 # NOTE 2\r\ndtim_period=2\r\ndump_file=\/tmp\/hostapd.dump\r\neapol_key_index_workaround=0\r\neap_server=0\r\nfragm_threshold=2346\r\nhw_mode=g #NOTE 3\r\nieee80211d=1\r\nieee80211n=1 #NOTE 4\r\nignore_broadcast_ssid=0\r\ninterface=wlan0 #NOTE 5\r\nlogger_stdout=-1\r\nlogger_stdout_level=2\r\nlogger_syslog=-1\r\nlogger_syslog_level=2\r\nmacaddr_acl=0\r\nmax_num_sta=16\r\nown_ip_addr=127.0.0.1\r\npreamble=1\r\nrsn_pairwise=CCMP\r\nrts_threshold=2347\r\nssid=dword-relay # NOTE 6\r\nwds_sta=1\r\nwmm_ac_be_acm=0\r\nwmm_ac_be_aifs=3\r\nwmm_ac_be_cwmax=10\r\nwmm_ac_be_cwmin=4\r\nwmm_ac_be_txop_limit=0\r\nwmm_ac_bk_acm=0\r\nwmm_ac_bk_aifs=7\r\nwmm_ac_bk_cwmax=10\r\nwmm_ac_bk_cwmin=4\r\nwmm_ac_bk_txop_limit=0\r\nwmm_ac_vi_acm=0\r\nwmm_ac_vi_aifs=2\r\nwmm_ac_vi_cwmax=4\r\nwmm_ac_vi_cwmin=3\r\nwmm_ac_vi_txop_limit=94\r\nwmm_ac_vo_acm=0\r\nwmm_ac_vo_aifs=2\r\nwmm_ac_vo_cwmax=3\r\nwmm_ac_vo_cwmin=2\r\nwmm_ac_vo_txop_limit=47\r\nwmm_enabled=1\r\nwpa=2\r\nwpa_gmk_rekey=7200\r\nwpa_group_rekey=1200\r\nwpa_passphrase=qwertyuiop #NOTE 7\r\nwpa_ptk_rekey=600\r\nwpa_strict_rekey=1\r\nwps_state=0<\/pre>\n<p>NOTES:<\/p>\n<ol>\n<li>\u5728\u8fd9\u91cc\u8bbe\u7f6e\u65b0\u751f\u6210\u7684 AP \u7684\u4fe1\u9053\uff0c\u6700\u597d\u548c STA \u754c\u9762\u8981\u8fde\u63a5\u7684 AP \u7684\u4fe1\u9053\u4fdd\u6301\u4e00\u81f4\uff1b<\/li>\n<li>\u9a71\u52a8\u89c6\u7f51\u5361\u800c\u5b9a\uff0c\u5982\u679c\u7f51\u5361\u7684\u9a71\u52a8\u662f ath9k \u8fd9\u6837\u57fa\u4e8e mac80211 \u7684\u9a71\u52a8\u7684\u8bdd\uff0c\u8fd9\u91cc\u9009 nl80211 \u5c31\u53ef\u4ee5\u4e86\uff1b<\/li>\n<li>\u6a21\u5f0f\u6709 a\/b\/g \u53ef\u9009\uff0c\u89c6\u7f51\u5361\u7684\u60c5\u51b5\u548c\u9700\u6c42\u800c\u5b9a\uff1b<\/li>\n<li>\u662f\u5426\u6253\u5f00 802.11n \uff0c\u89c6\u7f51\u5361\u7684\u60c5\u51b5\u548c\u9700\u6c42\u800c\u5b9a\uff1b<\/li>\n<li>\u7f51\u5361 AP \u754c\u9762\u540d\u79f0\uff1b<\/li>\n<li>\u65b0 AP \u7684 ESSID \uff1b<\/li>\n<li>\u65b0 AP \u7684 WPA2 \u5bc6\u7801\u53e5\uff1b<\/li>\n<li>\u5176\u4f59\u5173\u4e8e hostapd \u7684\u914d\u7f6e\u53ef\u53c2\u8003\uff1a<a href=\"http:\/\/hostap.epitest.fi\/gitweb\/gitweb.cgi?p=hostap-07.git;a=blob_plain;f=hostapd\/hostapd.conf;hb=HEAD\" target=\"_blank\">http:\/\/hostap.epitest.fi\/gitweb\/gitweb.cgi?p=hostap-07.git;a=blob_plain;f=hostapd\/hostapd.conf;hb=HEAD<\/a>\u00a0\uff1b<\/li>\n<li>\u5173\u952e\u662f\u628a wds_sta \u8bbe\u7f6e\u4e3a\u201c 1 \u201d\u3002<\/li>\n<\/ol>\n<p>\u6700\u540e\uff0csudo \u6267\u884c\u811a\u672c\uff0c\u7136\u540e\u901a\u8fc7 NetworkManager \u8ba9 wds0 \uff08\u6216\u8005\u5176\u4ed6\u4f60\u8bbe\u7f6e\u7684\u540d\u5b57\uff09\u8fde\u63a5\u4e0a\u4e00\u4e2a\u70ed\u70b9\uff0c\u5373\u53ef\u4e00\u8fb9\u8e6d\u7f51\u4e00\u8fb9\u5171\u4eab\u70ed\u70b9\u4e86\u3002<\/p>\n<p>\u6709\u56fe\u6709\u771f\u76f8\uff1a<\/p>\n<p><a href=\"http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2910\" title=\"wds\" src=\"http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds-400x203.png\" alt=\"\" width=\"400\" height=\"203\" srcset=\"http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds-400x203.png 400w, http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds-1024x521.png 1024w, http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds.png 1366w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds1.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-2908\" title=\"wds1\" src=\"http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds1-400x203.png\" alt=\"\" width=\"400\" height=\"203\" srcset=\"http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds1-400x203.png 400w, http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds1-1024x521.png 1024w, http:\/\/blog.dword1511.info\/wp-uploads\/2012\/11\/wds1.png 1366w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>\u53c2\u8003\uff1a<\/p>\n<ul>\n<li><a href=\"http:\/\/en.wikipedia.org\/wiki\/Wireless_distribution_system\" target=\"_blank\">http:\/\/en.wikipedia.org\/wiki\/Wireless_distribution_system<\/a><\/li>\n<li><a href=\"http:\/\/www.tummy.com\/journals\/entries\/jafo_20041220_000528\" target=\"_blank\">http:\/\/www.tummy.com\/journals\/entries\/jafo_20041220_000528<\/a>\u00a0\uff08\u9002\u7528\u4e8e\u8001\u673a\u5668\u4e0a\u8fc7\u65f6\u7684 madwifi \u9a71\u52a8\uff09<\/li>\n<li><a href=\"http:\/\/wireless.kernel.org\/en\/users\/Documentation\/iw#Setting_up_a_WDS_peer\" target=\"_blank\">http:\/\/wireless.kernel.org\/en\/users\/Documentation\/iw#Setting_up_a_WDS_peer<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e2a\u5e16\u5b50\u91cc\u7684\u65b9\u6cd5\u6709\u70b9\u8fc7\u65f6\u4e86\uff0c\u4e0d\u63a8\u8350\u7ee7\u7eed\u4f7f\u7528\u3002 \u6709\u7684\u65f6\u5019\u4f1a\u78b0\u5230\u8fd9\u4e48\u4e00\u79cd\u60c5\u51b5\uff0c\u5e26\u7740\u7535\u8111\u548c\u624b\u673a\u51fa\u53bb\u8e6d\u7f51\uff0c\u65e0\u5948\u53ea\u6709\u4e00\u4e2a &hellip; <a href=\"http:\/\/blog.dword1511.info\/?p=2906\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u8ba9\u65e0\u7ebf\u7f51\u5361\u540c\u65f6\u5de5\u4f5c\u5728 AP \u548c STA \u6a21\u5f0f<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[10,14],"tags":[],"_links":{"self":[{"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=\/wp\/v2\/posts\/2906"}],"collection":[{"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2906"}],"version-history":[{"count":5,"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=\/wp\/v2\/posts\/2906\/revisions"}],"predecessor-version":[{"id":4687,"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=\/wp\/v2\/posts\/2906\/revisions\/4687"}],"wp:attachment":[{"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2906"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2906"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.dword1511.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2906"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}