small thoughts and rfkill

搭建完k3s之后是时候该考虑部署服务了,准备用Nginx进行反代,但是我又不想通过端口区分设备遂决定在路由器上修改dnsmasq,解析到Nginx。

所以这就是目前的计划,准备在路由器上用host文件写几条域名映射到树莓派的节点上。

Anyway,found a new thing.

之前一直在纳闷为什么一直在路由器后台看到主机名为一个问号的设备,很是怪异,DHCP给它分配了v4的ip,查看了一下Mac地址发现制造商是树莓派,后来到节点上ifconfig了一下,发现了两个网络地址刚好吻合,一个是eth0,另一个是wlan,233333.

so it turns out 显示问号的DHCP是树莓派的Wi-Fi。不确定是何种原因Wi-Fi5的5GHz连接一直不是很稳定。

Anyway,还有个有趣的事情就是eth和wlan的网卡的mac地址刚好相邻。

估计是之前没有插网线的时候我先用的Wi-Fi。。。后来插了网线就Wi-Fi和有线共存了。

因为wlan传输的流量只有零星一点,至此我觉得只需要禁用一下Wi-Fi就好了,百度了一个禁用Wi-Fi的命令,在此记录一下。

看到了三种方案,其中一种我居然没想到我真的全责。

plan1:端口down掉

sudo ip link set wlan0 down

重启之后maybe恢复。

Plan2:改/boot/firmware/config.txt

我把/boot/firmware/config.txt启动里禁用了Wi-Fi总搞定了吧。。。

dtoverlay=disable-wifi

把如上语句添加到config里面去,理论上重启生效。不过也有可能语句有修改,我没试。

Plan3:rfkill命令

突然发现这内核级的Wi-Fi蓝牙控制命令,记录一下。

rfkill命令来自英文词组radio frequency kill的缩写,其功能是管理系统中的蓝牙和Wi-Fi设备,是一个内核级别的管理工具。

list所有的连接

1
2
3
4
5
6
7
$ rfkill list
0: hci0: Bluetooth
Soft blocked: no
Hard blocked: no
1: phy0: Wireless LAN
Soft blocked: no
Hard blocked: no

基本用法如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
$ rfkill --help

Usage:
rfkill [options] command [identifier ...]

Tool for enabling and disabling wireless devices.

Options:
-J, --json use JSON output format
-n, --noheadings don't print headings
-o, --output <list> define which output columns to use
--output-all output all columns
-r, --raw use the raw output format

-h, --help display this help
-V, --version display version

Available output columns:
DEVICE kernel device name
ID device identifier value
TYPE device type name that can be used as identifier
TYPE-DESC device type description
SOFT status of software block
HARD status of hardware block

Commands:
help
event
list [identifier]
block identifier
unblock identifier
toggle identifier

For more details see rfkill(8).

let‘s check一下man文档,既然它提到了有文档。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
RFKILL(8)                                                                           System Administration                                                                          RFKILL(8)

NAME
rfkill - tool for enabling and disabling wireless devices

SYNOPSIS
rfkill [options] [command] [ID|type ...]

DESCRIPTION
rfkill lists, enabling and disabling wireless devices.

The command "list" output format is deprecated and maintained for backward compatibility only. The new output format is the default when no command is specified or when the option
--output is used.

The default output is subject to change. So whenever possible, you should avoid using default outputs in your scripts. Always explicitly define expected columns by using the
--output option together with a columns list in environments where a stable output is required.

OPTIONS
-J, --json
Use JSON output format.

-n, --noheadings
Do not print a header line.

-o, --output
Specify which output columns to print. Use --help to get a list of available columns.

--output-all
Output all available columns.

-r, --raw
Use the raw output format.

-h, --help
Display help text and exit.

-V, --version
Print version and exit.
COMMANDS
help
Display help text and exit.

event
Listen for rfkill events and display them on stdout.

list [id|type ...]
List the current state of all available devices. The command output format is deprecated, see the DESCRIPTION section. It is a good idea to check with list command id or type
scope is appropriate before setting block or unblock. Special all type string will match everything. Use of multiple ID or type arguments is supported. Possible types are all,
{wlan | wifi}, bluetooth, {uwb | ultrawideband}, wimax, wwan, gps, fm, nfc.

block id|type [...]
Disable the corresponding device.

unblock id|type [...]
Enable the corresponding device. If the device is hard-blocked, for example via a hardware switch, it will remain unavailable though it is now soft-unblocked.

toggle id|type [...]
Enable or disable the corresponding device.

EXAMPLE
rfkill --output ID,TYPE
rfkill block all
rfkill unblock wlan
rfkill block bluetooth uwb wimax wwan gps fm nfc

AUTHORS
rfkill was originally written by Johannes Berg <[email protected]> and Marcel Holtmann <[email protected]>. The code has been later modified by Sami Kerola
<[email protected]> and Karel Zak <[email protected]> for the util-linux project.

This manual page was written by Darren Salt <[email protected]> for the Debian project (and may be used by others).

SEE ALSO
powertop(8), systemd-rfkill(8), Linux kernel documentation <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/driver-api/rfkill.rst>

REPORTING BUGS
For bug reports, use the issue tracker at https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The rfkill command is part of the util-linux package which can be downloaded from Linux Kernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.

1
2
3
4
$ rfkill --output-all
ID TYPE DEVICE TYPE-DESC SOFT HARD
0 bluetooth hci0 Bluetooth unblocked unblocked
1 wlan phy0 Wireless LAN blocked unblocked

Anyway 事已至此,我的方案是把三台树莓派上的蓝牙和Wi-Fi全部禁用。使用block命令带上ID或者TYPE都可以。


small thoughts and rfkill
https://steammilk.com/2025/01/05/2025-all/rfkill/
作者
蒸奶泡
发布于
2025年1月5日
更新于
2025年1月8日
许可协议