need to connect my pi via USB Ethernet to my WIFI PC (Linux Mint LMDE 3 Cindy) to connecting to the internet. I have changed my pi IP to by this instruction. After that, I have done the instruction base of this site and this which are for BBB in Linux MINT (Debian) and changed it for my PI by this way:

PI console can be got by using the following command

ssh -l pi

In the PI console type the following

sudo ifconfig usb0
sudo route add default gw

In the linux console of host system type

sudo su
#wlan0 is my internet facing interface, eth5 is the BeagleBone USB connection
ifconfig enp0s20f0u2
iptables --table nat --append POSTROUTING --out-interface wlp2s0 -j MASQUERADE
iptables --append FORWARD --in-interface enp0s20f0u2 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward

Incase network not accessible then type the following in PI terminal

echo "nameserver" >> /etc/resolv.conf

i gave problem switching my WiFi internet to Ethernet which solved by this instruction.

Finally get answer from my pi console when i ping to my WiFi IP ( based of ifconfig data, but i could not connect to internet


I have run this codes in my Laptop and its working:

# firstlu offing 
# Disable bridge interface
sudo ip link set br0 down
#wlp2s0 is my internet facing interface, enp0s20f0u2 is the Raspberry USB connection

sudo ifconfig enp0s20f0u2
sudo iptables --table nat --append POSTROUTING --out-interface wlp2s0 -j MASQUERADE
sudo iptables --append FORWARD --in-interface enp0s20f0u2 -j ACCEPT
sudo echo 1 > /proc/sys/net/ipv4/ip_forward
#and then in pc do this
sudo ip link set br0 up

I have this setting in my /etc/network/interfaces file :

so@notebook:~$ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback

iface enp0s20f0u1 inet static

allow-hotplug wlp2s0
#iface wlp2s0 

#auto br0
#  bridge_ports wlp2s0 enp0s20f0u1
#  bridge_stp off
#  bridge_fd 0
#  bridge_maxwait 0

but i don't know why it must disable and enable br0 in my IP setting to it working?!!! So what do you thinking?


What you are doing is creating a bridge on your host so that your network configuration looks something like this:

     LAN (
       |   enp0s20f0u1  |
       |                |
       |     wlp2s0     |

However, when you create the bridge, wlp2s0 still owns your LAN address (192.168.1.x most likely). But br0 must own that IP address to work, so by bringing it down then up, I'm guessing you are unwittingly forcing your network manager to re-assign your LAN address to the bridge.

If you want to know what is happening at a network level, you should use iproute2 (ip [command]) exclusively, instead of mixing ifconfig, ip and /etc/interfaces (the latter being a high level configuration file for you network manager which internally calls ip for you). Here is a good wiki page to get started.
Then you should setup your /etc/network/interfaces so that your network manager does it all automatically, without you needing to run ip commands manually. Normally, your network manager would just configure br0 with only wlp2s0 when your Raspberry Pi is disconnected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.