Article Title: how to create a personal Bluetooth Lan on the Linux platform. Linux is a technology channel of the IT lab in China. Including desktop applications, Linux system management, kernel research, embedded systems and open-source, and other basic categories. using bluetooth to build a personal wireless LAN on the Linux platform is convenient, practical, and flexible.
First, install bluez-libs, bluez-utils, and the bnep module in the kernel.
1: Start Bluetooth hciconfig hci0 up piscan
2: modprobe bnep
* The preceding steps must be performed on both the host and client.
3: run pand -- listen -- role NAP -- master on the host.
Run pand -- connect 00: 11: 67: 46: 4E: 4E -- role NAPU on the client.
00: 1167: 46: 4E: 4E is the address of the Bluetooth device.
4: When pand-l is used, you can see
Bnep0 00: 11: 67: 46: 4E: 4E PANU
The connection is successful.
5: set ifconfig bnep0 10.10.106.1 on the host
Set ifconfig bnep0 10.10.106.2 on the client
Now, you can ping 10.10.106.2 to 10.10.106.1.
To share Internet access, you need to use iptable on the host.
Add a route to the client
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' 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 |