Skip to content

Instantly share code, notes, and snippets.

@KyonLi
Last active May 10, 2023 07:05
Show Gist options
  • Save KyonLi/2ef330333f43c14d1c56676fd459dbe3 to your computer and use it in GitHub Desktop.
Save KyonLi/2ef330333f43c14d1c56676fd459dbe3 to your computer and use it in GitHub Desktop.
Debian / Ubuntu Setup Bluetooth Network Access Point (NAP)

Debian / Ubuntu Setup Bluetooth Network Access Point (NAP)

Requirements: Systemd, Network Manager

  1. Install required packages

    apt install bluez bluez-tools iptables dnsmasq-base

  2. Configure shared bridge interface br0

    nmcli c add type bridge ifname br0 ipv4.method shared ipv6.method ignore

  3. Put bt-agent.service and bt-network.service to /etc/systemd/system/

  4. Satrt services

    systemctl daemon-reload
    systemctl enable bt-agent
    systemctl enable bt-network
    systemctl restart bluetooth
    
[Unit]
Description=Bluetooth Agent
[Service]
#ExecStart=/usr/bin/bt-agent -c NoInputNoOutput
#Workaround for NoInputNoOutput not working. https://github.com/khvzak/bluez-tools/issues/31#issuecomment-782914364
ExecStart=/bin/sh -c '/usr/bin/yes | /usr/bin/bt-agent -c DisplayYesNo'
Type=simple
Restart=on-failure
[Install]
WantedBy=bluetooth.service
[Unit]
Description=Bluetooth NAP
After=sys-devices-virtual-net-br0.device
PartOf=sys-devices-virtual-net-br0.device bluetooth.service
[Service]
ExecStart=/usr/bin/bt-network -s nap br0
ExecStartPost=/usr/bin/bt-adapter --set Discoverable 1
Type=simple
[Install]
WantedBy=bluetooth.service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment