zoukankan      html  css  js  c++  java
  • 实用技巧:组建Linux下的个人蓝牙局域网

    用bluetooth 来组建个人的无线局域网,方便,实用而灵活。

    首先需要安装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

    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

    (责任编辑:A6)

  • 相关阅读:
    input 放大镜
    记住密码弹出事件
    thinkphp修改及编写标签库,编辑器的使用
    thinkphp 配合mongodb
    缓存技术
    php面试题目
    pdo 整套类的封装,保存修改查询
    mongodb 的备份恢复导入与导出
    mongodb 分组查询
    smarty 模板的入门使用
  • 原文地址:https://www.cnblogs.com/top5/p/1545241.html
Copyright © 2011-2022 走看看