Hello,
I’m looking to connect my BeagleBone to the net by sharing my connection from my mac through USB.
I know that this is possible and I’ve read many badly written explanations for it online, but none of them really laid it out in a step by step manner for someone who is relatively inexperienced with coding.
Could anybody explain how to do this?
Part of the challenge in explaining it clearly is that Apple has
broken Internet Connection Sharing on newer updates of Mac OS X.
When I want to enable connection sharing over USB, I run this script
on my Mac (you'll need a replacement for ssh-copy-id):
#!/bin/sh
GATEWAY_DEV=en0
HOST_DEV=en1
HOST_ADDR=192.168.7.1
BEAGLE_ADDR=192.168.7.2
sudo /sbin/ifconfig $HOST_DEV down
sudo /sbin/ifconfig bridge0 create
sudo /sbin/ifconfig bridge0 up
sudo /sbin/ifconfig bridge0 addm $GATEWAY_DEV
sudo /sbin/ifconfig bridge0 $HOST_ADDR
sudo /sbin/route add default -interface bridge0 -ifscope bridge0 -cloning
sudo /usr/sbin/sysctl -w net.inet.ip.forwarding=1
sudo /sbin/ipfw add 100 divert natd ip from any to any via $GATEWAY_DEV
sudo /usr/sbin/natd -interface $GATEWAY_DEV -use_sockets -same_ports
-unregistered_only -dynamic -clamp_mss -enable_natportmap
-natportmap_interface $HOST_DEV
The Problem is, that you destroy your own connection whilst being connected over it.
You start of by connecting to the BBB via USB and SSH? root@192.168.7.2 ← this is the IP of the BBB when the session begins
Then you run the command to ask for a NEW IP for that interface via DHCP and your router answers.
The router has different DHCP-range gives the interface a new IP. That new IP is NOT THE SAME as your current IP. Hence the IP changes and therefore destroys your connection.
I hope I could help you.
I am currently looking for a way to keep the IP on USB0 and still have internet access with my BBB.
Should I find something, I will let you know