<div id="article_content" class="article_content clearfix"> <div class="article-copyright"> <span class="creativecommons"> <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/"> </a> <span> 版权声明:本文为博主原创文章,遵循<a href="http://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="noopener"> CC 4.0 BY-SA </a>版权协议,转载请附上原文出处链接和本声明。 </span> <div class="article-source-link2222"> 本文链接:<a href="https://blog.csdn.net/ac_dao_di/article/details/71908444">https://blog.csdn.net/ac_dao_di/article/details/71908444</a> </div> </span> </div> <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/ck_htmledit_views-3019150162.css"> <div id="content_views" class="markdown_views"> <!-- flowchart 箭头图标 勿删 --> <svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path> </svg> <h3 id="1-查看无线网卡是否支持ap模式"><a name="t0"></a>1. 查看无线网卡是否支持AP模式</h3>

<p>&nbsp;&nbsp;&nbsp;&nbsp;要创建一个热点,必须有无线网卡,且该网卡支持AP模式,具体可以用如下命令查看:</p>

<pre class="prettyprint" name="code"><code class="hljs applescript has-numbering" onclick="mdcp.copyCode(event)" style="position: unset;">sudo apt-<span class="hljs-keyword">get</span> install iw iw <span class="hljs-type">list</span><div class="hljs-button {2}" data-title="复制"></div></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li></ul></pre>

<p>&nbsp;&nbsp;&nbsp;&nbsp;如果出现如下包含AP的关键字,则表示支持AP模式:</p>

<p><img src="https://img-blog.csdn.net/20170513210537410?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>

<h3 id="2-创建热点"><a name="t1"></a>2. 创建热点</h3>

<p>&nbsp;&nbsp;&nbsp;&nbsp;首先点击右上角的网络图标,然后拉到最下面,点击编辑连接,得到如下界面:</p>

<p><img src="https://img-blog.csdn.net/20170513210933760?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""> <br> &nbsp;&nbsp;&nbsp;&nbsp;点击增加,然后选择wi-fi,点击新建,得到如下界面:</p>

<p><img src="https://img-blog.csdn.net/20170513211128917?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""> <br> &nbsp;&nbsp;&nbsp;&nbsp;这时填写连接的名称,填写SSID,也就是到时热点显示的名称,在模式里选择热点,Ubuntu 16.04有这个选项。。。Ubuntu 15.04死活没找到。。。如下:</p>

<p><img src="https://img-blog.csdn.net/20170513211406902?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""> <br> &nbsp;&nbsp;&nbsp;&nbsp;然后点击Wi-Fi安全性选项卡,在安全下拉框中选择WPA及WPA个人。注意WEP已经不安全,而且手机连接WiFi基本使用WPA PSK模式来验证。如下: <br> <img src="https://img-blog.csdn.net/20170513211959274?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""> <br> &nbsp;&nbsp;&nbsp;&nbsp;然后在切到IPv4设置选项卡,在方法里选择”与其他计算机共享“:</p>

<p><img src="https://img-blog.csdn.net/20170513212233621?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""> <br> &nbsp;&nbsp;&nbsp;&nbsp;最后切到IPv6设置选项卡,在方法下拉框选择忽略:</p>

<p><img src="https://img-blog.csdn.net/20170513212409685?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""> <br> &nbsp;&nbsp;&nbsp;&nbsp;点击保存后,可以在/etc/NetworkManager/system-connections/下看到刚创建的连接对应的wifi-test文件:</p>

<p><img src="https://img-blog.csdn.net/20170513212751878?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""> <br> &nbsp;&nbsp;&nbsp;&nbsp;打开该文件:</p>

<pre class="prettyprint" name="code"><code class="hljs ini has-numbering" onclick="mdcp.copyCode(event)" style="position: unset;"><span class="hljs-title">[connection]</span> <span class="hljs-setting">id=<span class="hljs-value">wifi-test</span></span> <span class="hljs-setting">uuid=<span class="hljs-value">ebd62f6f-b5b5-<span class="hljs-number">46</span>d7-becf-bd3f17efa753</span></span> <span class="hljs-setting">type=<span class="hljs-value">wifi</span></span> <span class="hljs-setting">permissions=<span class="hljs-value"></span></span> <span class="hljs-setting">secondaries=<span class="hljs-value"></span></span> <span class="hljs-title">[wifi]</span> <span class="hljs-setting">mac-address-blacklist=<span class="hljs-value"></span></span> <span class="hljs-setting">mac-address-randomization=<span class="hljs-value"><span class="hljs-number">0</span></span></span> <span class="hljs-setting">mode=<span class="hljs-value">ap</span></span> <span class="hljs-setting">seen-bssids=<span class="hljs-value"></span></span> <span class="hljs-setting">ssid=<span class="hljs-value">wifi-test</span></span> <span class="hljs-title">[wifi-security]</span> <span class="hljs-setting">group=<span class="hljs-value"></span></span> <span class="hljs-setting">key-mgmt=<span class="hljs-value">wpa-psk</span></span> <span class="hljs-setting">pairwise=<span class="hljs-value"></span></span> <span class="hljs-setting">proto=<span class="hljs-value"></span></span> <span class="hljs-setting">psk=<span class="hljs-value">你的wifi密码</span></span> <span class="hljs-title">[ipv4]</span> <span class="hljs-setting">dns-search=<span class="hljs-value"></span></span> <span class="hljs-setting">method=<span class="hljs-value">shared</span></span> <span class="hljs-title">[ipv6]</span> <span class="hljs-setting">addr-gen-mode=<span class="hljs-value">stable-privacy</span></span> <span class="hljs-setting">dns-search=<span class="hljs-value"></span></span> <span class="hljs-setting">ip6-privacy=<span class="hljs-value"><span class="hljs-number">0</span></span></span> <span class="hljs-setting">method=<span class="hljs-value">ignore</span></span><div class="hljs-button {2}" data-title="复制"></div></code><ul class="pre-numbering" style=""><li style="color: rgb(153, 153, 153);">1</li><li style="color: rgb(153, 153, 153);">2</li><li style="color: rgb(153, 153, 153);">3</li><li style="color: rgb(153, 153, 153);">4</li><li style="color: rgb(153, 153, 153);">5</li><li style="color: rgb(153, 153, 153);">6</li><li style="color: rgb(153, 153, 153);">7</li><li style="color: rgb(153, 153, 153);">8</li><li style="color: rgb(153, 153, 153);">9</li><li style="color: rgb(153, 153, 153);">10</li><li style="color: rgb(153, 153, 153);">11</li><li style="color: rgb(153, 153, 153);">12</li><li style="color: rgb(153, 153, 153);">13</li><li style="color: rgb(153, 153, 153);">14</li><li style="color: rgb(153, 153, 153);">15</li><li style="color: rgb(153, 153, 153);">16</li><li style="color: rgb(153, 153, 153);">17</li><li style="color: rgb(153, 153, 153);">18</li><li style="color: rgb(153, 153, 153);">19</li><li style="color: rgb(153, 153, 153);">20</li><li style="color: rgb(153, 153, 153);">21</li><li style="color: rgb(153, 153, 153);">22</li><li style="color: rgb(153, 153, 153);">23</li><li style="color: rgb(153, 153, 153);">24</li><li style="color: rgb(153, 153, 153);">25</li><li style="color: rgb(153, 153, 153);">26</li><li style="color: rgb(153, 153, 153);">27</li><li style="color: rgb(153, 153, 153);">28</li><li style="color: rgb(153, 153, 153);">29</li><li style="color: rgb(153, 153, 153);">30</li></ul></pre>

<p>&nbsp;&nbsp;&nbsp;&nbsp;可以发现已经使用了mode=ap模式,使用了wpa-psk来认证,psk显示了认证的密码,同时ipv4的method=shared,ipv6的method=ignore,说明界面的操作最后都保留到这个文件中。如果无线网卡真的支持AP,则就算前面的界面中没有热点这个选项,也可以修改这个配置文件的mode=ap来实现,因为Linux中一切皆为文件。</p>

<h3 id="3-使用热点"><a name="t2"></a>3. 使用热点</h3>

<p>&nbsp;&nbsp;&nbsp;&nbsp;最后先让计算机连接有线网,然后点击右上角的网络图标点击连接到隐藏网络选项(如果已经连接先断开),选择刚才创建的wifi-test。这时点击右上角网络图标下拉框选择连接信息,可以得到如下,表示连接成功:</p>

<p><img src="https://img-blog.csdn.net/20170513214306291?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""> <br> &nbsp;&nbsp;&nbsp;&nbsp;使用手机或者其他电脑连接wifi-test,同样可以上网:</p>

<p><img src="https://img-blog.csdn.net/20170513214628013?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;使用另外一台Ubuntu 15.04主机连接wifi-test热点,查看连接信息,可以发现使用的网关刚好是开热点的主机的无线网卡的IP地址(10.42.0.1)。。。也就是被作为网关了,开启热点的主机必须进行自我连接作为网关,否则还是上不了网。。。</p>

<p><img src="https://img-blog.csdn.net/20170513215255444?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvYWNfZGFvX2Rp/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" alt="这里写图片描述" title=""></p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;参考博客: <br> <a href="https://linux.cn/article-6172-1.html" rel="nofollow" data-token="dbf5faff8eec5e3d4f2d9225f83944ec">https://linux.cn/article-6172-1.html</a></p> </div> <link href="https://csdnimg.cn/release/phoenix/mdeditor/markdown_views-095d4a0b23.css" rel="stylesheet"> </div>

08-28 18:08