1

I have following network structure

PC  <-- USB cable -->   Android Smartphone <--> MyWiFi
IP=192.168.42.41        IP=192.168.35.115       IP=192.168.35.254
NM=255.255.255.0        NM=???                  NM=255.255.255.0
DG=192.168.42.129       DG=???                  DG=???

Laptop <--------------> MyWiFi
IP=192.168.35.112       IP=192.168.35.254
NM=255.255.255.0        NM=255.255.255.0
DG=192.168.35.254       DG=???

... where MyWiFi is my home WiFi network

Note: The PC can "ping" the Laptop, but the Laptop cannot "ping" the PC.

When I traceroute 192.168.35.254 from the PC, I get the following:

traceroute 192.168.35.254
traceroute to 192.168.35.254 (192.168.35.254), 30 hops max, 60 byte packets
 1  192.168.42.129 (192.168.42.129)  2.163 ms  2.870 ms  3.339 ms
 2  192.168.35.254 (192.168.35.254)  14.562 ms  14.915 ms  11.876 ms

Routing from the laptop is:

ip route
default via 192.168.35.254 dev wlp2s0  proto static  metric 600 
169.254.0.0/16 dev wlp2s0  scope link  metric 1000 
192.168.35.0/24 dev wlp2s0  proto kernel  scope link  src 192.168.35.112  metric 600 

So it seems confirmed that my Android Phone stands as gateway between the PC and the WIFI router.

Both computers PC and Laptop have Ubuntu installed and Nautilus + Samba in order to share folders. The problem is that the PC cannot see the share folders of the Laptop

I have already shared folders between other computers that connect directly to MyWiFi, but I think in this case the tethering is spoiling the sharing.

How can I share folders, even though I am connecting the PC to the WiFi via tethering?

  • How is the PC tethered to the Android? Cable? Bluetooth? can the PC ping the default gateway of MyWiFi? Can it ping 1.1.1.1? Please [edit] your question to provide this valuable info and then leave a comment @Fabby 0:-) – Fabby Jul 18 '19 at 22:14
  • This is confusing,... are you sure you use tethering ? – Robert Riedl Jul 19 '19 at 13:25
  • @Fabby Thanks for the questions. I just did what you asked for. Every ping worked properly. – loved.by.Jesus Jul 19 '19 at 13:46
  • Ah. Please [edit] your question and provide the whole picture in the PC <-- USB cable --> Android Smartphone <--> MyWiFi line: all of their IP addresses and Default gateways because you don't have a samba issue but a networking issue. also add the full samba config to https://paste.ubuntu.com and provide a link to that in your question too. so make your question easy to understand from a full networking perspective... ;-) – Fabby Jul 19 '19 at 14:11
  • @Fabby Hey guys, I do not think I can provide more useful infos. The full samba config, how can I get it? ´:-) (I think I deserve part of the bounty ;)) – loved.by.Jesus Jul 19 '19 at 21:18
  • @user68186 can I mount folders with sftp or sshfs? But may be I loose the power of being in a local network. If I use an application that goes through the internet, then the data transmission is much slower. ;) I want to connect in Local Network – loved.by.Jesus Jul 19 '19 at 21:36
  • @loved.by.Jesus samba config is located in /etc/samba/smb.conf. Please see my revision to your question and please fill in the blanks I.E. ??? as you're having a network problem, not a samba problem. – Fabby Jul 19 '19 at 21:58
  • 1
    I agree with @Fabby this is a network issue, specifically having two subnets. The simple solution would be to connect the PC to the router by an Ethernet cable or a WiFi dongle. Then you will have both PC and laptop on the same subnet. – user68186 Jul 19 '19 at 22:30
  • @Fabby Here is the samba configuration https://paste.ubuntu.com/p/3Q67DJ6Spc/ Please, tell me which command do I have to use to get the addresses of my smartphone. By the way, thanks a lot (!) the edits on my question look neat. – loved.by.Jesus Jul 20 '19 at 15:45
  • I don't know what you have installed on your Android so that is more of an [android.se] question. If you have filled in all the ??? I can give you a solution that will work for the entire network. If you do, please ping me again... :-) – Fabby Jul 20 '19 at 18:19
  • @Fabby, yes please present a solution. It can be a blessing for anyone looking for an answer, or even trying to learn a bit more of networking in linux – loved.by.Jesus Jul 20 '19 at 20:11
  • You have to [edit] your question and fill in the ??? first. @loved.by.Jesus I need all the information to make it work as you wish. With the information I currently have, the only thing I can answer now is: Put samba on the PC instead of the laptop... (which is probably not what you want.) – Fabby Jul 20 '19 at 20:17

2 Answers2

2

Here your Android Smartphone indeed works as gateway but partially you also have to configure routes from laptop side.

The reason behind PC cannot see the share folders of the Laptop is that Laptop routes packets through your wifi router. You need configure your android smartphone's ip address as gateway in your laptop.

Currently gateway of laptop is router. Please remove 192.168.35.254 ip address and configure smartphone as gateway 192.168.35.115 in your laptop's network configuration. After applying configuration, it should work.

You can check routes of laptop using route -n command.

KK Patel
  • 19,083
  • 1
    Thanks a lot @Ketan Patel, it really worked! Just by replacing the gateway I could access the PC from the laptop and, not only ping the PC's address, but also mount samba from the laptop by standard command smb://192.168.42.41/folder_name on nautilus – loved.by.Jesus Jul 23 '19 at 21:40
0

Because the PC can "ping" the Laptop, I can at least access the Samba shared folders of the Laptop (IP 192.168.35.112) from the PC. I have to use following command in the nautilus bar of the PC.

smb://192.168.35.112/name-of-shared-folder

In that way I can do at least exchange from the PC.

Caveat

The same as the other answers. The IP of the Laptop may change, and therefore the command should be adapted.