28 June 2025

Access internet on Raspberry Pi when connected to two network interfaces

I had a Raspberry Pi 3B connected via LAN cable to a Wifi router which wasn't connected to the internet. Through the router I could connect to the RPi via my desktop PC's Wifi. So VNC and SSH worked nicely in terms of being able to view the RPi desktop and being able to exchange files via scp. However, when I activated my phone's hotspot and the RPi's Wifi connected to the hotspot, I could not access internet.

I soon found out that this happened because the RPi gave a higher priority to the LAN connection than to the Wifi hotspot. So it was just a matter of changing the priority in a few simple steps.

Type `ip route show` to see the existing connections. You may see something like this:

default via 192.168.1.1 dev eth0 proto dhcp src 192.168.1.2 metric 100

default via 192.168.42.1 dev wlan0 proto dhcp src 192.168.42.125 metric 600

What this means is that the gateway for the LAN connection (eth0) is 192.168.1.1 and the IP is 192.168.1.2. The gateway for the wireless connection (wlan0) is 192.168.42.1 and the IP is 192.168.42.125. Since the LAN is listed first, it has the higher priority. So you simply need to add the route to the wireless IP address:

sudo ip route add default via 192.168.42.125 dev wlan0 

You can confirm it got added to the top of the list by typing `ip route show`.

Then simply restart the network service. If `sudo systemctl restart networking` or `service networking restart` gives this error: `Failed to restart networking.service: Unit networking.service not found`, then you can simply type (it didn't disrupt my VNC connection):

sudo ifconfig eth0 down && sudo ifconfig eth0 up &

This will restart eth0 and you'll be able to connect to the internet. You can check by typing:

ping 8.8.8.8 

04 June 2025

Accessing an Android phone via ADB using a Linux desktop PC

It turns out, one way to reduce the size of a Flutter app, is by splitting it into builds for each specific device architecture you want. So if you type:

flutter clean; flutter build apk --split-per-abi 

It'll give an output like:

✓ Built build/app/outputs/flutter-apk/app-armeabi-v7a-release.apk (6.9MB)
✓ Built build/app/outputs/flutter-apk/app-arm64-v8a-release.apk (7.4MB)
✓ Built build/app/outputs/flutter-apk/app-x86_64-release.apk (7.6MB) 

Now I needed to know which one I could use on my phone, and realized that in all these years, I didn't bother finding out what architecture my phone was running. 

So I activated Developer Options and USB Debugging on my phone and did the following:

sudo apt update; sudo apt install adb

Now ADB (Android Debug Bridge) should be installed. To see which devices you can connect to via ADB, type:

adb devices

You'll be asked on your phone for permission to do USB debugging. Grant it.

Now either type: 

adb shell uname -m

Or, just:

adb shell

And then type:

uname -m

And now I know the phone is armv7l, which is an ARM 32 bit architecture.

So now I know I could have also tried:

flutter build apk --target-platform android-arm --analyze-size


There are many other ADB commands:

To copy files: 

adb pull /path/to/phone/file /path/to/desktop/folder

Mount the phone onto the Linux filesystem:

sudo apt install adbfs
mkdir ~/android
adbfs ~/android

Now you can access the files via your desktop computer at ~/android

To get elevated permissions with ADB:

adb kill-server
sudo adb start-server
adb devices

For more commands, simply type:

man adb