Set up a personal Bluetooth LAN under Linux

  
                  

Use bluetooth to build a personal wireless LAN, convenient, practical and flexible.

First you need to install bluez-libs, bluez-utils, and the benep module in the kernel.

1: Start Bluetooth hciconfig hci0 up piscan

2: modprobe bnep

*The above steps must be performed on both the host and the client

< BR>3: On the host, run pand --listen --role NAP --master

On the client, run pand --connect 00:11:67:46:4E:4E --role NAPU

4: When using pand -l you can see

bnep0 00:11:67:46:4E:4E PANU

Description Connection success

5: Set ifconfig bnep0 10.10.106.1 on the host.

Set ifconfig bnep0 10.10.106.2


on the client. You can ping from 10.10.106.2 to 10.10.106.1. Br>


If you need to share the Internet, you need to use iptable on the host to set it up.

Client to add route

route add -net default gw 10.10.106.1


The following is my iptable script.

#!/bin/bash

IPTABLES='/usr/sbin/iptables'

# Set interface values ​​

EXTIF='ppp0' < Br>

INTIF1='bnep0'

# enable ip forwarding in the kernel

/bin/echo 1 > /proc/sys/net/ipv4/ip_forward

# flush rules and delete chains

$IPTABLES -F

$IPTABLES -X

# enable masquerading to allow LAN internet access

$IPTABLES -t nat -A POSTROUTING -o $EXTIF -j MASQUERADE

# forward LAN traffic from $INTIF1 to Internet interface $EXTIF

$IPTABLES -A FORWARD -i $INTIF1 -o $EXTIF -m state --state NEW,ESTABLISHED -j ACCEPT

#echo -e " - Allowing access to the SSH server"

$IPTABLES -A INPUT --protocol tcp --dport 22 -j ACCEPT

#echo -e " - Allowing access to the HTTP server"

$IPTABLES -A INPUT --protocol tcp --dport 80 -j ACCEPT

Copyright © Windows knowledge All Rights Reserved