Linux系统平台下架建个人蓝牙局域网方法

资讯 驱动中国 317 次阅读 0 条评论
分享 Q
 

用bluetooth 在 Linux平台下架建个人的无线局域网,方便,实用而灵活。

首先需要安装bluez-libs、bluez-utils,还有内核中的bnep模块。

1: 启动蓝牙hciconfig hci0 up piscan

2: modprobe bnep

*以上步骤,在主机和和客户机上都要操作

3: 在主机上,运行pand --listen --role NAP --master

在客户机上,运行pand --connect 00:11:67:46:4E:4E --role NAPU

00:1167:46:4E:4E 为蓝牙设备的地址

4: 当用pand -l 能看到

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

说明连接成功

5: 在主机上设置ifconfig bnep0 10.10.106.1

在客户机上设置ifconfig bnep0 10.10.106.2

至此,你就可以从10.10.106.2 ping 到10.10.106.1

若需要共享上网,则需要在主机上用iptable来设置一下。

客户机要添加route

route add -net default gw 10.10.106.1

以下是我的iptable的脚本。

#!/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
版权声明:本文由驱动中国整理发布,转载需注明出处与原文链接。如有疑问请联系 editor@qudong.com
本文价值 成为第一个评分的人
登录后为本文打分
网友评论0 条评论
正在回复 的评论取消
评论加载中…
🔐

登录后参与互动

评论、点赞均可赚积分
连续签到、邀请好友也有奖励 🎁

电脑端: 微信扫码登录 微信内: 一键登录

微信扫一扫

打开微信「扫一扫」,分享本文到朋友圈或好友