Traffic forwarding for SSH over different interface

Job ID: 32608236

Budget: €8 – €30 EUR

Hi!

I have an ubuntu server running on my raspberry pi 400. There are 4 Interfaces connected on it.
Output of route command:
eth1 192.168.1.10 metric: 0
eth2 192.168.3.10 metric: 0
eth3 192.168.3.10 metric: 0
wifi0 10.0.0.50 metric: 400

The interfaces eth1, eth2, eth3 are mobile 4g routers with cellular sim card conntected to the internet. With an own written script i switch the main internet traffic between this eth 1/2/3 interfaces in an loop. For this i run in circle the command "sudo route add default gw eth1" for example. Because this setup i cant connect to one of this ethernet interfaces because the IP adresses on them are dynamic and chaning each time, so i also setup an wifi0 interface while my home internet has an paid static IPv4 address wich i could connect anytime over ssh to my raspi. The problem is just that this is just possible when the wifi0 interface is set as main traffic interface on top of the list what i want prevent. I want this wifi0 interface just work as my ssh connection point to reach my raspi from public internet. The eth interfaces shouldnt be interrupted by wifi0, and wifi0 never go to handle main traffic or else. So as far as i could research on stackoverflow on my own, is that i would need an forwarding rule to say ubuntu "all traffic (incoming / outgoing) with port 22 should be forwarded to wifi0. My goal is to connect to my ubuntu over ssh over this wifi0 static ip adress while its on metric 400, and the main traffic is going over this eth interfaces. Hoping to get an permanently solution to setup this routing, or an command to do it temporary wich i would then put in an script and run it on bootup of system. To be sure its working i will not award anyone before i check your solution on tested on my local server. As its working perfectly as im expecting you get awared and paid out.

Thanks!
Related categories: Linux Ubuntu Debian Network Administration