【迁移】树莓派开启蓝牙个人区域网

Last updated on October 27, 2024 pm

开启 SSH 连接

  • boot 目录下新建 ssh 的空文件
  • boot 目录下新建 wpa_supplicant.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="Limour123"
psk="123456"
key_mgmt=WPA-PSK
priority=5
}

network={
ssid="Redmi_719_2.4G"
psk="123456"
key_mgmt=WPA-PSK
priority=1
}

蓝牙局域网设置

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
sudo apt install bridge-utils bluez python-dbus python-gobject bluez-tools
sudo ufw disable # 关闭防火墙
sudo service bluetooth start # 开启蓝牙服务并设置为开机自启
sudo update-rc.d bluetooth enable

sudo nano /etc/systemd/network/pan0.netdev
# 输入:
[NetDev]
Name=pan0
Kind=bridge

sudo nano /etc/systemd/network/pan0.network
# 输入:
[Match]
Name=pan0

[Network]
Address=172.20.1.1/24
DHCPServer=yes

sudo nano /etc/systemd/system/bt-agent.service
# 输入:
[Unit]
Description=Bluetooth Auth Agent

[Service]
ExecStart=/usr/bin/bt-agent -c NoInputNoOutput
Type=simple

[Install]
WantedBy=multi-user.target

sudo nano /etc/systemd/system/bt-network.service
# 输入:
[Unit]
Description=Bluetooth NEP PAN
After=pan0.network

[Service]
ExecStart=/usr/bin/bt-network -s nap pan0
Type=simple

[Install]
WantedBy=multi-user.target

sudo systemctl enable systemd-networkd
sudo systemctl enable bt-agent
sudo systemctl enable bt-network
sudo systemctl start systemd-networkd
sudo systemctl start bt-agent
sudo systemctl start bt-network

连接蓝牙局域网

1
2
3
4
5
bluetoothctl # 启动蓝牙命令行工具
agent on # 开启代理
scan on # 扫描设备
pair 9C:19:C2:4D:88:DC # 树莓派与蓝牙设备进行配对
connect 9C:19:C2:4D:88:DC # 连接设备
  • win11 上右键蓝牙加入个人区域网
  • 树莓派上 ifconfig 可以看到多了一个 bnep0 的网络
  • win11ipconfig.exe 可以看到多了一个以太网适配器 蓝牙网络连接
  • 其默认网关为 172.20.1.1
  • 此时 win11ssh 连接 172.20.1.1 即可连接到树莓派

【迁移】树莓派开启蓝牙个人区域网
https://hexo.limour.top/ssh-by-bluetooth-in-raspberrypi
Author
Limour
Posted on
March 31, 2020
Updated on
October 27, 2024
Licensed under