2

I need to install remotely Omxplayer on a Raspberry Pi. RPi is connected by a LTE modem through PPP0 interface. My RPI is placed another country and I connect to Raspberry through my VPN using SSH. My VPN does not have access to Internet and the default gateway is 10.1.64.1 (PPP0).

RPI has also WiFi Connection: WLAN0 interface. I want to use WLAN0 to launch:"sudo apt-get install omxplayer" without lost my SSH communication through PPP0

ifconfig lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 184 bytes 11776 (11.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 184 bytes 11776 (11.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ppp0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500 inet 10.1.64.45 netmask 255.255.255.255 destination 10.64.64.64 ppp txqueuelen 3 (Point-to-Point Protocol) RX packets 202 bytes 25021 (24.4 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 808 bytes 65151 (63.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.93 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::2db7:3540:5e17:a470 prefixlen 64 scopeid 0x20<link> ether b8:27:eb:da:d6:37 txqueuelen 1000 (Ethernet) RX packets 1806 bytes 369775 (361.1 KiB) RX errors 0 dropped 620 overruns 0 frame 0 TX packets 184 bytes 25229 (24.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 

If I change the default gateway, I lost connectivity with the device. I have tried the following command but it has not worked: I have lost the ssh connection.

sudo ip route change default via 192.168.1.1 dev wlan0 sudo route add default gw 192.168.1.1 

My route table:

$ route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 0.0.0.0 0.0.0.0 U 0 0 0 ppp0 0.0.0.0 192.168.1.1 0.0.0.0 UG 302 0 0 wlan0 10.64.64.64 0.0.0.0 255.255.255.255 UH 0 0 0 ppp0 169.254.0.0 0.0.0.0 255.255.0.0 U 203 0 0 wwan0 192.168.1.0 0.0.0.0 255.255.255.0 U 302 0 0 wlan0 $ ip route show default dev ppp0 scope link default via 192.168.1.1 dev wlan0 src 192.168.1.205 metric 302 10.64.64.64 dev ppp0 proto kernel scope link src 10.1.64.54 169.254.0.0/16 dev wwan0 proto kernel scope link src 169.254.104.103 metric 203 192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.205 metric 302 

How can I select the network interface?

Thanks in advance

6
  • Please share the route table (ip route show) Commented Feb 19, 2021 at 9:35
  • ok, I just put it on. Thanks @BruceMalaudzi Commented Feb 19, 2021 at 9:39
  • Your current VPN setup is assuming that all traffic to internet must be pushed through the tunnel ppp0. We can tell by the mertic value of zero [0]. But you said VPN has no internet access. That is why you are failing to install packages. Out of interest, whats the use of this VPN that has no internet access? Commented Feb 19, 2021 at 9:44
  • It is a device used for telemetry but now we want to play videos on it. We connect to the device remotely and want to install the video program. Commented Feb 19, 2021 at 9:50
  • Either disconnect from VPN when internet access is needed, or configure VPN with "split tunneling" Commented Feb 19, 2021 at 9:51

1 Answer 1

1

If I understand correctly you have this arrangement:

(Client)---LAN?---(VPN)---ppp0---(Raspberry Pi)---wlan0---(the internet) 

You mentioned that when you change your default route to use wlan0, you lose SSH access. You also indicated that you can't access the internet through ppp0 (through your VPN).


If you just want your r-pi to have internet access...

You can't SSH into your PI when you change the default route because the default route is the only one that can get to your SSH client. So what you can do is add a new route to talk back to your SSH client then change your default route.

A really simple / dirty way to fix this temporarily is:

# Find your current SSH client IP address as seen by the raspberry pi env | grep SSH_CLIENT 

Then assuming this gives you the IP 10.20.30.40 add a route to just that IP:

ip route add 10.20.30.40 dev ppp0 proto kernel scope link # Now you can change your default route ip route change default via 192.168.1.1 dev wlan0 

A better way to do this is to discover which subnet(s) can be accessed through ppp0 and then create routes for those instead of just your one SSH client. I can't tell how to find these subnets. But once you have this, the technique is the same. (eg subnet 10.20.0.0/16):

ip route add 10.20.0.0/16 dev ppp0 proto kernel scope link # Now you can change your default route ip route change default via 192.168.1.1 dev wlan0 
2
  • Thank you so much. It works!. Out of interest, I would like to know why you think it is a dirty solution. Commented Feb 19, 2021 at 12:38
  • 1
    Doing it for just your IP is the "dirty" solution. The reason being that in general your IP could change without warning. I don't know your network infrastructure, but there's always a possibility that your laptop's IP lease could expire, it would ask for a new one from the DHCP server and might not get the same one back. If you configure it to route to your subnet then your IP could change within your subnet and things would all just carry on working. Commented Feb 19, 2021 at 13:16

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.