• 实用技巧:组建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)

  • 相关阅读:
    Linux下的输入/输出重定向
    strcpy与strncpy的区别
    C++的函数重载
    gtest 学习二
    gtest 学习一
    char* wchar* char wchar转换
    iconv 编译不通过问题
    嵌入式常用库
    驱动编程class_create说明
    libiconv 交叉编译
  • 原文地址:https://www.cnblogs.com/top5/p/1545241.html
Copyright © 2020-2023  润新知