In this tutorial you’ll see the steps I took took to share the Internet connection from my Mac with my Pi-Star running on a Raspberry Pi Zero W. In some areas my Wi-Fi connection isn’t great and this is a way that I can use the wired Ethernet connection that my Mac uses.
Use the Pi-Star Dashboard to access the SSH Terminal app. I won’t go into how to use command-line editing tools in this tutorial. I use VIM to edit the files. Access the SSH terminal from the Pi-Star Dashboard > Configuration > Expert > SSH Access page. Log in as pi-star
(default password is: raspberry
).
Enter Read-Write Mode
By default Pi-Star runs in read-only mode and since we’ll be changing a few files, make sure to enter read-write mode by entering the following command:
$ rpi-rw
NOTE: the $
shown above is just indicating the terminal prompt.
Enable Raspberry Pi to run in Gadget Mode
Edit /boot/config.txt
Add the following line to the end of the file:
dtoverlay=dwc2
Edit /boot/cmdline.txt
Add the following (on the same line) right after rootwait
:
modules-load=dwc2,g_ether
After the change, your /boot/cmdline.txt
file should look something like this (all one line):
dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait modules-load=dwc2,g_ether fastboot noswap ro
Edit /etc/network/interfaces
Add these lines after the iface eth0 net manual
line:
allow-hotplug usb0
iface usb0 net dhcp
Restart and Configure Internet Sharing
- Shut down and power off your hotspot in your normal way
- Plug in a USB cable from your Mac to your hotspot using the Micro USB port marked as USB (not the power port)
- Wait for your hotspot to boot
- Open the System Preferences app on your Mac by selecting it from the Menu at the top left of your Mac
- Go to the Sharing settings
- Inside the Internet Sharing section a new option (RNDIS/Ethernet Gadget) should appear as one of the options
- If it does not appear, wait for a few minutes and reboot the hotspot again. On one of my computers it took a couple reboots.
- With the Internet Sharing option unchecked, check/enable the RNDIS/Ethernet Gadget port
- Turn Internet Sharing back on
- Reboot your Pi-Star Hotspot again
- Check to see that your hotspot is using the shared connection from your Mac by either:
- Transmitting from your digital radio and observing the bottom part of your Pi-Star screen (it should show
usb0: <IP Address>
) - Use SSH Access to print out the network interfaces to verify that usb0 has an IP Address by running the following:
- Transmitting from your digital radio and observing the bottom part of your Pi-Star screen (it should show
$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
2: usb0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 86:03:63:9f:db:47 brd ff:ff:ff:ff:ff:ff
inet 192.168.2.5/24 brd 192.168.2.255 scope global usb0
valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:68:96:bc brd ff:ff:ff:ff:ff:ff
inet 192.168.230.6/16 brd 192.168.255.255 scope global wlan0
valid_lft forever preferred_lft forever
Change your Hotspot Fallback Mode Password
When you connect your Pi-Star hotspot through Internet sharing, that won’t stop the Wi-Fi from automatically trying to connect. If it finds one of your configured Wi-Fi networks it will also connect to that. If it doesn’t, it will put the Wi-Fi radio in fallback mode (unless you’ve disabled Auto AP in the dashboard). I like the ability to have the fallback mode available if I ever take my hotspot some place new and want to easily connect. But, changing your Pi-Star main password does not change your fallback Wi-Fi password. To do this (a very good idea), edit /etc/hostapd/hostapd.conf
and change wpa_passphrase
to something besides the default of raspberry
. Just make sure you remember the password.
Other Notes
I haven’t taken any steps to disable Wi-Fi and so you’ll see above that my network interfaces also shows a Wi-Fi connection. From the Pi-Star dashboard you should see activity once you connect to a talkgroup. In my case, I no longer see a high loss percentage.
If you have any suggestions or additional tips, please let me know in the comments or shoot me an email.
Comments