Score:0

Force ftp to use USB hotspot interface

de flag

Background: My home broadband speed is very slow, so I use my mobile hotspot (5G, unlimited data) to download large files. Currently, to store media on my NAS I download the file to my phone, then transfer to my NAS via USB.

I want to move to directly connecting my NAS to the media server via FTP and download files that way, but I need the NAS to use my mobile data hotspot whilst also staying on my home ethernet for access from local devices like my main desktop. When I tether my phone to my NAS, I see "usb0" in the list of network interfaces.

My question is, how do I force the ftp application to connect to the media server via the usb0 interface? I've seen threads like: https://unix.stackexchange.com/questions/210982/bind-unix-program-to-specific-network-interface

But when I follow this example, I don't get any connection with e.g. curl returning "Could not resolve host". I've got fairly basic level knowledge in UNIX. My local network is enp3s0 at 192.168.4.X.

paladin avatar
kr flag
Do you use a hostname for connecting or do you use an IP? If you use a hostname for connecting, instead use the IP of the host, which you wanna connect to. If you want to use a hostname, add that hostname and it's **fixed** IP to your `/etc/hosts` file.
jpbrain avatar
ca flag
Hi @Faris. This is done by setting specific routes to the host or network you are trying to reach. You could specify different networks and then create the specific routes through them.
de flag
@paladin Are you talking about hostname vs IP for connecting to the NAS? I use my internal local IP to connect to the NAS, it's not accessible externally, and a hostname to connect to the FTP (which fails to connect when I follow the example steps on the link)
de flag
@jpbrain Interesting, I've got quite basic knowledge in Linux but I'll look into this thanks!
paladin avatar
kr flag
It seems you have problems with resolving hostnames. What I meant to say was: Don't use the hostname of that FTP server to connect to that FTP server, instead use its IP address.
de flag
@paladin Makes sense, thank you
Score:0
ca flag

Here it is a more detailed answer.
On any unix/linux machine you setup every interface with at least 3 parameters:

IP, Default Gateway/Route and Netmask
IP: is the actual direction for your inteface
Gateway: is the primary contact to reach other networks
Netmask: Would be a definition of what actually is your local network

then there is the DNS that it is only needed when you want to resolve out of the network host/IPs. If you configure names in the /etc/hosts then you know the translation between the name and the local IPs.

Now. if you have more than one way to reach the network you could use something like:

ROUTE add [destination] [MASK netmask] [gateway] [METRIC metric] [IF interface]

here you tell the server to use [gateway] to reach [destination] on a specific [IF interface]
using this you bind the routes by IP/Interface and it is not related to the program you are using.

Please, go ahead and google the specifics and try it.

Good luck.

de flag
I got it working, thanks for the explanation!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.