大路朝天勇往直前 發表於 2023-11-24 00:00:00

Ubuntu开机自动禁用无线网络的方法

<p>
        <span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>研究了一下,大致有2个比较简单方法,可以让ubuntu开机自动禁用无线网络。 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>自启动脚本 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将下面这条禁用无线网络的命令添加到“启动应用程序“中,这样开机时无线网络就会被自动禁用。 </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        dbus-send --system --type=method_call --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager org.freedesktop.DBus.Properties.Set string:org.freedesktop.NetworkManager string:WirelessEnabled variant:boolean:false </p>
<p>
        <br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><img title="Ubuntu开机自动禁用无线网络的方法" alt="Ubuntu开机自动禁用无线网络的方法" src="https://zhuji.jb51.net/uploads/img/202305/1cffa11cc3a189a89caf56a6e2bf60bb.jpg" style="max-width:100%!important;height:auto!important;border: 1px solid rgb(204, 204, 204); vertical-align: middle; padding: 1px; overflow: hidden; max-width: 816px; font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px; width: 581px; height: 417px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这是最灵活也是最行之有效的方法,唯一的不足在于,电脑从待机状态下唤醒时,无线网络还是会被重新启用。 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>2、驱动黑名单 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>将无线网卡驱动加入黑名单,彻底禁用无线网络。 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>既然是禁用驱动,首先我们得知道无线网卡的驱动名是什么,在终端中输入lshw命令可以列出电脑硬件的详细信息,从中我们可以获取无线网卡的驱动名。下面是信息片段: </span></p>
<div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <p class="right">
                <span><u>复制代码</u></span></p>
        <p>
                代码如下:</p>
</div>
<p class="msgborder" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        *-network <br>
        description: Wireless interface <br>
        product: PRO/Wireless 3945ABG Network Connection <br>
        vendor: Intel Corporation <br>
        physical id: 0 <br>
        bus info: pci@0000:03:00.0 <br>
        logical name: wlan0 <br>
        version: 02 <br>
        serial: <br>
        width: 32 bits <br>
        clock: 33MHz <br>
        capabilities: bus_master cap_list ethernet physical wireless <br>
        configuration: broadcast=yes driver=iwl3945 latency=0 multicast= </p>
<p>
         </p>
<ul>
<li>
                最后一行显示我的无线网卡驱动名称是iwl3945(intel 3945abg无线网卡),将它加入到黑名单就可以了,具体操作如下:</li>
        <li>
                sudo gedit /etc/modprobe.d/blacklist.conf</li>
        <li>
                在文本最后加入 blacklist iwl3945</li>
        <li>
                重新启动</li>
        <li>
                如果的确长时间不会用到无线网络,这个方法就比较干净彻底。</li>
</ul>
<p style='margin: 0px; padding: 5px 0px; outline: none; font-size: 14px; line-height: 30px; font-family: tahoma, arial, "Microsoft YaHei";'>
        如果学习了<font color="#0068b4">配置interfaces文件</font>,也可以完全抛开NetworkManager,更加灵活地控制网络设定。现在也渐渐能体会到Linux将配置文件全部写成文本文档的优点所在了。</p>
頁: [1]
查看完整版本: Ubuntu开机自动禁用无线网络的方法