使用OS X中的USB与BeagleBone Black共享Internet的步骤 [英] Steps to share internet with BeagleBone Black using USB from OS X

查看:140
本文介绍了使用OS X中的USB与BeagleBone Black共享Internet的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经尝试:

  1. 使用USB将BBB连接到iMac
  2. 通过系统偏好设置"->共享"与委员会共享互联网
  3. ssh到板,然后尝试udhcp -i usb0

这就是它的意思:

  1. udhcpc (v1.20.2) started
  2. 被卡住了,我得到了一个错误:Write failed: Broken pipe
  3. ssh退出
  1. udhcpc (v1.20.2) started
  2. Gets stuck and I get and error: Write failed: Broken pipe
  3. ssh exits

有任何线索吗?

推荐答案

您的SSH会话被卡住了,因为您已连接到usb0,而udhcpc命令更改了它的IP地址!此时,在ssh会话的另一端没有任何监听,因此本地计算机的ssh客户端最终会因管道错误而失败并退出.

Your SSH session is getting stuck because you're connected to usb0 and the udhcpc command changed the IP address for it! At this point there's nothing listening on the other end of your ssh session, so your local computer's ssh client eventually fails with the broken pipe error and exits.

一个明显的解决方法是通过tty.usbserial而不是ssh连接到IP地址.您可能会认为usb端口的分配IP不应更改.继续阅读以了解发生了什么.

An obvious workaround is to connect via tty.usbserial instead of ssh to the IP address. You'd think the usb port's assigned IP shouldn't be changing though. Read on to understand what's happening.

大多数第一次使用BBB的人都使用提供的USB电缆将他们直接连接到与Internet连接的计算机上.这正是BBB设计师想要为您做的事情,并且他们在BBB的启动网页上做得非常出色.

Most people using a BBB for the first time attach them directly to their Internet connected computer using the supplied USB cable. It's exactly what the BBBs designers intended for you to do, and they've done a fantastic job with the BBBs startup web page.

该主机共享它的连接的方式有所不同,具体取决于它是Windows,OS X还是Linux,以及如何执行它取决于所运行的OS版本.

That host computer shares it connection differently though depending on whether it's Windows, OS X or Linux, and how you do it varies depending on the version of the OS you're running.

Derek Molloy(探索BeagleBone )和Jason Kridner(

Derek Molloy (Exploring BeagleBone) and Jason Kridner (Youtube OS X Beaglebone video) provide some fairly detailed instructions to use host based Internet sharing with your BBB. The Linux and Windows instructions are still good, but they need to update the OS X info for Yosemite - Apple switched their NAT and firewall software to pf from ipfw and natd. If you try running udhcpc like Jason did in his vid it doesn't work the same way as his did.

因此回到OS X Yosemite的BBB SSH问题.这是怎么回事:使用串行/FTDI电缆连接到BBB,然后检查bbonebone的usb0 ip配置.

So back to your BBB SSH problem with OS X Yosemite. Here's how to see what's going on: Connect to the BBB using a serial/FTDI cable, then check the ip config of usb0 for the beaglebone.

beaglebone:~# ifconfig -a usb0
usb0      Link encap:Ethernet  HWaddr 0e:be:ff:00:ff:00 inet addr:192.168.7.2
          Bcast:192.168.7.3  Mask:255.255.255.252

确认您可以ping共享其Internet连接的主机

confirm you can ping the host that's sharing it's Internet connection

beaglebone:~# ping 192.168.7.1
PING 192.168.7.1 (192.168.7.1) 56(84) bytes of data.
64 bytes from 192.168.7.1: icmp_req=1 ttl=64 time=0.681 ms
64 bytes from 192.168.7.1: icmp_req=2 ttl=64 time=0.533 ms
^C

尝试访问Internet IP(google dns)

try reaching an Internet IP (google dns)

beaglebone:~# ping 8.8.8.8
connect: Network is unreachable

检查路由并确认没有默认路由,这就是上述ping失败的原因(默认情况下,连接USB的BBB具有192.168.7.0/30网络设置,因此只能达到192.168.7.0,.1,...). 2和.3地址).

check routes and confirm there's no default route out, which is why the ping above failed (a USB connected BBB has a 192.168.7.0/30 network setup by default, so it can only reach 192.168.7.0, .1, .2 and .3 addresses).

beaglebone:~# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.7.0     0.0.0.0         255.255.255.252 U         0 0          0 usb0

因此,如果您运行udhcpc,它将为您添加缺少的路由.您也可以直接添加路由,但是还需要设置dns,并且使用OS X Internet共享,并且不更改BBB的IP地址就无法使用-请参阅本文结尾处的链接帖子)

so if you run udhcpc it will add the missing route for you. you could also just add the route directly, but you need to setup dns as well, and with OS X Internet sharing it won't work without also changing the BBB's IP address - see links at end of this post)

beaglebone:~# udhcpc -i usb0
udhcpc (v1.20.2) started
Sending discover...
Sending discover...

,这里是udhcpc更改IP的地方,而不仅仅是重新使用192.168.7.2.新IP与OS X Internet共享使用的IP范围兼容,因此这可能就是DHCP服务器返回它的原因.

and here is where udhcpc changes the IP instead of just re-using 192.168.7.2. The new IP is compatible with the IP range used by OS X Internet Sharing, so that may be why the DHCP server is returning it.

Sending select for 192.168.2.34...
Lease of 192.168.2.34 obtained, lease time 85536

udhcpc然后抛出错误,因为没有默认的删除路径

udhcpc then throws an error because there's no default route to delete

/etc/udhcpc/default.script: Resetting default routes

SIOCDELRT: No such process

udhcpc然后添加默认路由-请仔细注意,这是OS X Internet共享192.168.2地址,而不是原始的192.168.7.

udhcpc then adds the default route - note carefully it's an OS X Internet Sharing 192.168.2 address, not the original 192.168.7.

/etc/udhcpc/default.script: Adding DNS 192.168.2.1

一切正常,因此您可以看到新路由并立即成功ping外部IP

everything worked, so you can see the new route and successfully ping an external IP now

beaglebone:~# netstat -rn
Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG        0 0          0 usb0
192.168.2.0     0.0.0.0         255.255.255.0   U         0 0          0 usb0

beaglebone:~# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_req=1 ttl=53 time=4.08 ms
64 bytes from 8.8.8.8: icmp_req=2 ttl=53 time=3.59 ms
^C

有几篇博客文章显示了如何永久设置:

There are a couple of blog posts that show how to set this up permanently:

通过USB将OS X Internet连接共享到BeagleBone黑色

在BeagleBone Black上更改usb0 IP地址

这篇关于使用OS X中的USB与BeagleBone Black共享Internet的步骤的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆