Hardware Reference
In-Depth Information
echo
"to enable forwarding of packets. Then run the following:"
echo
"$ sudo sysctl -p"
exit
1
else
echo
"IP forwarding is set on host."
fi
#
Set up IP masquerading on the host so the bone can reach the outside
world
sudo iptables
-
t nat
-
A POSTROUTING
-
s $beagleAddr
-
o $interface
-
j
MASQUERADE
Then, on your host, run the following commands:
host$
chmod +x ipMasquerade.sh
host$
./ipMasquerade.sh eth0
This will direct your host to take requests from the Bone and send them to
eth0
. If your
host is using a wireless connection, change
eth0
to
wlan0
.
Now let's set up your host to instruct the Bone what to do. Add the code in
Example 5-2
to
setDNS.sh
on your host computer.
Example 5-2. Code for setting the DNS on the Bone (setDNS.sh)
#!/bin/bash
#
These are the commands to run on the host so the Bone
#
can access the Internet through the USB connection
.
#
Run
./
ipMasquerade
.
sh the first time
.
It will set up the host
.
#
Run
this
script
if
the host is already set up
.
hostAddr
=
192.168
.
7.1
beagleAddr
=
192.168
.
7.2
#
Save the
/
etc
/
resolv
.
conf on the Bone
in case
we mess things up
.
ssh root
@
$beagleAddr
"mv -n /etc/resolv.conf /etc/resolv.conf.orig"
#
Create our own resolv
.
conf
cat
- <<
EOF
>
/tmp/resolv.conf
#
This is installed by host
.
setDNS
.
sh on the host
EOF
#
Look up the nameserver of the host and add it to our resolv
.
conf
nmcli dev list
|
grep IP4
.
DNS
|
sed
's/IP4.DNS\[.\]:/nameserver/'
>>
/tmp/resolv.conf
scp
/
tmp
/
resolv
.
conf root
@
$beagleAddr
:
/etc