如何使 USB 网络共享功能在 15.10 和 Android 设备之间运行?

如何使 USB 网络共享功能在 15.10 和 Android 设备之间运行?

环境:Dell L502X 上的 Ubuntu 15.10

我以前能够毫无问题地在 Ubuntu 和 Android 设备之间使用 USB 网络共享。去年年底,我在笔记本上安装了全新的 Ubuntu (15.10)。现在,使用这种组合,我无法使用 USB 网络共享。我尝试过 Nexus 4(运行 Android 5.1,以前可以与我之前使用的 Ubuntu 15.04 配合使用)、Nexus 5(运行 Android 6.0.1)和 Nexus 5X(运行 Android 6.0.1)。

ifconfig当我启用 USB 网络共享时,我在输出中得到一个新条目:

enx92c991095e89 Link encap:Ethernet  HWaddr 92:c9:91:09:5e:89  
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:7 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:520 (520.0 B)  TX bytes:0 (0.0 B)

请注意,硬件地址会随着每次网络共享而变化,因此关闭 USB 网络共享然后重新打开,或者切换到不同的 Nexus 设备,我会得到一个替换条目:

enx82fb7388a85c Link encap:Ethernet  HWaddr 82:fb:73:88:a8:5c  
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:4 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000 
      RX bytes:332 (332.0 B)  TX bytes:0 (0.0 B)

我还在系统设置的“网络”屏幕中获得相应的有线条目,显示与节匹配的硬件地址ifconfig,并描述为“已断开连接”(对于当前启用的 USB 网络共享会话)或“未管理”(对于之前的 USB 网络共享会话)。

启用或禁用 GUFW 对问题没有影响。直接连接或通过 USB 集线器连接对问题没有影响。

我的/etc/network/interfaces标准是:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

在 Ubuntu 15.10 上我还需做其他什么操作才能使 Android USB 网络共享功能正常运行?

更新:以下是@bain 请求的日志:

Jan 16 08:22:09 L502X kernel: [ 5377.812495] usb 1-1: new high-speed USB device number 3 using xhci_hcd
Jan 16 08:22:09 L502X kernel: [ 5377.945753] usb 1-1: New USB device found, idVendor=18d1, idProduct=4ee2
Jan 16 08:22:09 L502X kernel: [ 5377.945763] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 16 08:22:09 L502X kernel: [ 5377.945768] usb 1-1: Product: Nexus 5X
Jan 16 08:22:09 L502X kernel: [ 5377.945772] usb 1-1: Manufacturer: LGE
Jan 16 08:22:09 L502X kernel: [ 5377.945776] usb 1-1: SerialNumber: 00f204f982a4b8b9
Jan 16 08:22:10 L502X org.gtk.Private.GPhoto2VolumeMonitor[1780]: (process:2108): GVFS-GPhoto2-WARNING **: device (null) has no BUSNUM property, ignoring
Jan 16 08:22:10 L502X kernel: [ 5378.080031] [UFW BLOCK] IN=enp6s0 OUT= MAC= SRC=fe80:0000:0000:0000:16fe:b5ff:febb:2732 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8612 LEN=24 
Jan 16 08:22:10 L502X kernel: [ 5378.080049] [UFW BLOCK] IN=enp6s0 OUT= MAC= SRC=fe80:0000:0000:0000:16fe:b5ff:febb:2732 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8610 LEN=24 
Jan 16 08:22:10 L502X kernel: [ 5378.090303] [UFW BLOCK] IN=enp6s0 OUT= MAC= SRC=fe80:0000:0000:0000:16fe:b5ff:febb:2732 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8612 LEN=24 
Jan 16 08:22:10 L502X kernel: [ 5378.090319] [UFW BLOCK] IN=enp6s0 OUT= MAC= SRC=fe80:0000:0000:0000:16fe:b5ff:febb:2732 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8610 LEN=24 
Jan 16 08:22:11 L502X org.gtk.Private.GPhoto2VolumeMonitor[1780]: (process:2108): GVFS-GPhoto2-WARNING **: device (null) has no BUSNUM property, ignoring
Jan 16 08:22:11 L502X colord[1165]: (colord:1165): Cd-WARNING **: CdMain: failed to emit DeviceAdded: failed to register object: An object is already exported for the interface org.freedesktop.ColorManager.Device at /org/freedesktop/ColorManager/devices/sysfs__null_
Jan 16 08:22:14 L502X colord-sane: io/hpmud/musb.c 2081: Invalid usb_open: Permission denied
Jan 16 08:22:30 L502X kernel: [ 5398.876832] usb 1-1: USB disconnect, device number 3
Jan 16 08:22:31 L502X kernel: [ 5399.213700] usb 1-1: new high-speed USB device number 4 using xhci_hcd
Jan 16 08:22:31 L502X kernel: [ 5399.346845] usb 1-1: New USB device found, idVendor=18d1, idProduct=4ee4
Jan 16 08:22:31 L502X kernel: [ 5399.346855] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 16 08:22:31 L502X kernel: [ 5399.346860] usb 1-1: Product: Nexus 5X
Jan 16 08:22:31 L502X kernel: [ 5399.346864] usb 1-1: Manufacturer: LGE
Jan 16 08:22:31 L502X kernel: [ 5399.346868] usb 1-1: SerialNumber: 00f204f982a4b8b9
Jan 16 08:22:31 L502X mtp-probe: checking bus 1, device 4: "/sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb1/1-1"
Jan 16 08:22:31 L502X mtp-probe: bus: 1, device: 4 was not an MTP device
Jan 16 08:22:31 L502X kernel: [ 5399.385223] usbcore: registered new interface driver cdc_ether
Jan 16 08:22:31 L502X kernel: [ 5399.392871] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:04:00.0-1, RNDIS device, 9a:ff:bd:ee:76:ea
Jan 16 08:22:31 L502X kernel: [ 5399.392918] usbcore: registered new interface driver rndis_host
Jan 16 08:22:31 L502X NetworkManager[1070]: <warn>  (usb0): failed to find device 4 'usb0' with udev
Jan 16 08:22:31 L502X NetworkManager[1070]: <info>  (usb0): new Ethernet device (carrier: OFF, driver: 'rndis_host', ifindex: 4)
Jan 16 08:22:31 L502X kernel: [ 5399.398467] rndis_host 1-1:1.0 enx9affbdee76ea: renamed from usb0
Jan 16 08:22:31 L502X NetworkManager[1070]: <info>  (usb0): interface index 4 renamed iface from 'usb0' to 'enx9affbdee76ea'
Jan 16 08:22:31 L502X NetworkManager[1070]: <info>  devices added (path: /sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb1/1-1/1-1:1.0/net/enx9affbdee76ea, iface: enx9affbdee76ea)
Jan 16 08:22:31 L502X NetworkManager[1070]: <info>  device added (path: /sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb1/1-1/1-1:1.0/net/enx9affbdee76ea, iface: enx9affbdee76ea): no ifupdown configuration found.
Jan 16 08:22:31 L502X NetworkManager[1070]: <info>  (enx9affbdee76ea): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
Jan 16 08:22:31 L502X kernel: [ 5399.442941] IPv6: ADDRCONF(NETDEV_UP): enx9affbdee76ea: link is not ready
Jan 16 08:22:31 L502X NetworkManager[1070]: <info>  (enx9affbdee76ea): link connected
Jan 16 08:22:31 L502X NetworkManager[1070]: <info>  (enx9affbdee76ea): device state change: unavailable -> disconnected (reason 'none') [20 30 0]
Jan 16 08:22:31 L502X NetworkManager[1070]: <info>  Device 'enx9affbdee76ea' has no connection; scheduling activate_check in 0 seconds.
Jan 16 08:22:31 L502X kernel: [ 5399.458876] [UFW BLOCK] IN=enp6s0 OUT= MAC= SRC=fe80:0000:0000:0000:16fe:b5ff:febb:2732 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8612 LEN=24 
Jan 16 08:22:31 L502X kernel: [ 5399.458904] [UFW BLOCK] IN=enp6s0 OUT= MAC= SRC=fe80:0000:0000:0000:16fe:b5ff:febb:2732 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8610 LEN=24 
Jan 16 08:22:31 L502X kernel: [ 5399.469062] [UFW BLOCK] IN=enp6s0 OUT= MAC= SRC=fe80:0000:0000:0000:16fe:b5ff:febb:2732 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8612 LEN=24 
Jan 16 08:22:31 L502X kernel: [ 5399.469088] [UFW BLOCK] IN=enp6s0 OUT= MAC= SRC=fe80:0000:0000:0000:16fe:b5ff:febb:2732 DST=ff02:0000:0000:0000:0000:0000:0000:0001 LEN=64 TC=0 HOPLIMIT=1 FLOWLBL=0 PROTO=UDP SPT=8612 DPT=8610 LEN=24 
Jan 16 08:22:33 L502X ModemManager[1081]: <info>  Couldn't find support for device at '/sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb1/1-1': not supported by any plugin
Jan 16 08:22:35 L502X colord-sane: io/hpmud/musb.c 2081: Invalid usb_open: Permission denied

更新 #2:通过 GUFW 禁用防火墙后,获得新鲜的系统日志:

Jan 16 09:33:23 L502X kernel: [ 9649.766835] usb 1-1: new high-speed USB device number 6 using xhci_hcd
Jan 16 09:33:23 L502X kernel: [ 9649.900519] usb 1-1: New USB device found, idVendor=18d1, idProduct=4ee2
Jan 16 09:33:23 L502X kernel: [ 9649.900529] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 16 09:33:23 L502X kernel: [ 9649.900534] usb 1-1: Product: Nexus 5X
Jan 16 09:33:23 L502X kernel: [ 9649.900538] usb 1-1: Manufacturer: LGE
Jan 16 09:33:23 L502X kernel: [ 9649.900542] usb 1-1: SerialNumber: 00f204f982a4b8b9
Jan 16 09:33:23 L502X org.gtk.Private.GPhoto2VolumeMonitor[1780]: (process:2108): GVFS-GPhoto2-WARNING **: device (null) has no BUSNUM property, ignoring
Jan 16 09:33:24 L502X org.gtk.Private.GPhoto2VolumeMonitor[1780]: (process:2108): GVFS-GPhoto2-WARNING **: device (null) has no BUSNUM property, ignoring
Jan 16 09:33:24 L502X colord[1165]: (colord:1165): Cd-WARNING **: CdMain: failed to emit DeviceAdded: failed to register object: An object is already exported for the interface org.freedesktop.ColorManager.Device at /org/freedesktop/ColorManager/devices/sysfs__null_
Jan 16 09:33:26 L502X kernel: [ 9652.898664] usb 1-1: USB disconnect, device number 6
Jan 16 09:33:26 L502X kernel: [ 9653.233755] usb 1-1: new high-speed USB device number 7 using xhci_hcd
Jan 16 09:33:26 L502X kernel: [ 9653.367239] usb 1-1: New USB device found, idVendor=18d1, idProduct=4ee4
Jan 16 09:33:26 L502X kernel: [ 9653.367249] usb 1-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
Jan 16 09:33:26 L502X kernel: [ 9653.367254] usb 1-1: Product: Nexus 5X
Jan 16 09:33:26 L502X kernel: [ 9653.367258] usb 1-1: Manufacturer: LGE
Jan 16 09:33:26 L502X kernel: [ 9653.367262] usb 1-1: SerialNumber: 00f204f982a4b8b9
Jan 16 09:33:26 L502X kernel: [ 9653.375259] rndis_host 1-1:1.0 usb0: register 'rndis_host' at usb-0000:04:00.0-1, RNDIS device, 4e:8a:8f:3f:b7:cb
Jan 16 09:33:26 L502X NetworkManager[1070]: <warn>  (usb0): failed to find device 5 'usb0' with udev
Jan 16 09:33:26 L502X NetworkManager[1070]: <info>  (usb0): new Ethernet device (carrier: OFF, driver: 'rndis_host', ifindex: 5)
Jan 16 09:33:26 L502X mtp-probe: checking bus 1, device 7: "/sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb1/1-1"
Jan 16 09:33:26 L502X mtp-probe: bus: 1, device: 7 was not an MTP device
Jan 16 09:33:26 L502X kernel: [ 9653.420245] rndis_host 1-1:1.0 enx4e8a8f3fb7cb: renamed from usb0
Jan 16 09:33:26 L502X NetworkManager[1070]: <info>  (usb0): interface index 5 renamed iface from 'usb0' to 'enx4e8a8f3fb7cb'
Jan 16 09:33:26 L502X NetworkManager[1070]: <info>  devices added (path: /sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb1/1-1/1-1:1.0/net/enx4e8a8f3fb7cb, iface: enx4e8a8f3fb7cb)
Jan 16 09:33:26 L502X NetworkManager[1070]: <info>  device added (path: /sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb1/1-1/1-1:1.0/net/enx4e8a8f3fb7cb, iface: enx4e8a8f3fb7cb): no ifupdown configuration found.
Jan 16 09:33:26 L502X NetworkManager[1070]: <info>  (enx4e8a8f3fb7cb): device state change: unmanaged -> unavailable (reason 'managed') [10 20 2]
Jan 16 09:33:26 L502X NetworkManager[1070]: <info>  (enx4e8a8f3fb7cb): link connected
Jan 16 09:33:26 L502X kernel: [ 9653.447746] IPv6: ADDRCONF(NETDEV_UP): enx4e8a8f3fb7cb: link is not ready
Jan 16 09:33:26 L502X NetworkManager[1070]: <info>  (enx4e8a8f3fb7cb): device state change: unavailable -> disconnected (reason 'none') [20 30 0]
Jan 16 09:33:26 L502X NetworkManager[1070]: <info>  Device 'enx4e8a8f3fb7cb' has no connection; scheduling activate_check in 0 seconds.
Jan 16 09:33:27 L502X colord-sane: io/hpmud/musb.c 2081: Invalid usb_open: Permission denied
Jan 16 09:33:28 L502X ModemManager[1081]: <info>  Couldn't find support for device at '/sys/devices/pci0000:00/0000:00:1c.3/0000:04:00.0/usb1/1-1': not supported by any plugin

更新 #3route -n启用 USB 网络共享后,之后sudo dhclient ...

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 enx16d44e6a2773
192.168.42.0    0.0.0.0         255.255.255.0   U     0      0        0 enx16d44e6a2773

答案1

好吧,感谢贝恩开始回答,你几乎解决了它:)

按照你说的做了,你还是不能上网,也不能做诸如此类的事情ping google.com,很烦人。

但是,一切看起来都正常(路由、ifconfig、/etc/resolv.conf 指向 127.0.1.1……)。为了确保万无一失,我尝试 ping 一个来自谷歌的已知 IP(206.169.145.232),成功了!该死,我不知道为什么 DNS 也坏了,但您可以使用临时解决方法,即编辑 /etc/resolv.conf,将 127.0.1.1 替换为 8.8.8.8(甚至添加第二行nameserver 8.8.4.4)。

您已设置完毕,可以再次浏览网页了!

现在,如果有人能弄清楚为什么 kubuntu 15.10(也受到这个错误的影响)不能像以前一样自动执行此操作,那就太好了。

享受。

答案2

实际情况是,您的 USB0 接口已被 rndis_host 驱动程序重命名为 enx4e8a8f3fb7cb。只需编辑您的 /etc/network/interfaces 文件,将 USB0 接口替换为 rdis_host 驱动程序重命名的接口即可。

要在插入手机并激活网络共享功能后找出这一点,请在终端中运行“ifconfig -a”,您将看到新的随机生成的接口,同样您将不再看到 USB0,因为它已被 rndis_host 驱动程序重命名。

答案3

这个问题不是在 Ubuntu 上,我在 Windows 7 上也遇到了同样的问题

由于某种原因,PC 无法通过 DNS 识别 Android 网络,为了解决此问题,您是否在 Android 上使用任何阻止连接应用程序?

如果是,请禁用它,然后尝试使用 USB 网络共享,如果出现同样的问题,请执行以下操作:

  1. 从 Google Play 安装(设置 DNS 或 DNS 更改器)
  2. 设置 Google DNS

    DNS1:8.8.8.8

    DNS2:8.8.4.4

然后按连接,之后尝试启用 USB 网络共享。

它应该有效

相关内容