Force ftp to use USB hotspot interface

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.

Answers 1

  • 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.


Related Questions