Openwrt-USB网络共享

1.openwrt 使用 android 手机usb tether联网

openwrt是一个是个用于嵌入式设备的linux发行版,支持目前市面上大量的路由器设备。基于buildroot构建的文件系统使其拥有海量的可用软件包,具有超强的拓展能力,移植,添加,裁剪十分灵活,相信在未来的智能家庭,物联网领域将有匡阔前景。现在智能路由器大多基于openwrt。

运行openwrt的智能路由器大多会带有至少一个usb口,通过usb口可以拓展很多应用,可以外接存储设备(u盘,移动硬盘)作为存储服务器,流媒体服务器,外接打印机,外接usb camera可以实现远程监控,由于usb强大的通用功能,可拓展的功能很多。

通过usb口外接3g,4G(lte)dongle,并将其作为wan口,就能实现mifi的功能。

在没有dongle的情况下,也可以把android手机通过数据线连接到openwrt box上,通过android的tether功能使用手机的移动网络,openwrt的配置如下:

1 需要的软件包:kmod-usb-net kmod-usb-net-rndis kmod-usb-net-cdc-ether usbutils udev


opkg update

opkg install kmod-usb-net kmod-usb-net-rndis kmod-usb-net-cdc-ether usbutils udev

2 配置

手机通过usb线连接到路由器。

在手机上,打开tether功能(usb共享网络)。

在路由器端,lsusb,查看是否探测到你的手机:


root@OpenWrt:/# lsusb

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Bus 002 Device 003: ID 1782:5d21 Spreadtrum Communications Inc.

Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

显示发现一个rndis设备,并注册为接口usb0, ifconfig -a查看是否存在usb0接口:

把usb0设置为WAN口:


uci del network.wan

uci set network.wan=interface

uci set network.wan.ifname=usb0

uci set network.wan.proto=dhcp

uci commit network

重启WAN口:


ifdown wan

ifup wan

查看是否拨上


root@OpenWrt:/# ifconfig usb0

usb0      Link encap:Ethernet  HWaddr EA:3C:7D:81:C4:10 

          inet addr:192.168.42.15  Bcast:192.168.42.255  Mask:255.255.255.0

          inet6 addr: fe80::e83c:7dff:fe81:c410/64 Scope:Link

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:7104 errors:4 dropped:0 overruns:0 frame:4

          TX packets:3952 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:8507336 (8.1 MiB)  TX bytes:456085 (445.3 KiB)

root@OpenWrt:/# ping baidu.com

PING baidu.com (123.125.115.110): 56 data bytes

64 bytes from 123.125.115.110: seq=0 ttl=50 time=79.260 ms

64 bytes from 123.125.115.110: seq=1 ttl=50 time=89.016 ms

文献:https://blog.csdn.net/whfyzg/article/details/47125273

猜你喜欢

转载自blog.csdn.net/weixin_34232617/article/details/87340259
今日推荐