0

Suppose you have two computers, A and B, both running Ubuntu 16.04. Then you connect them with an ethernet cable and share the connection from A to B, using network manager with the option "Shared with other computers". This usually gives A the IP 10.42.0.1, but if that IP Class is already taken (for example in A you have a wifi hotspot connection set before plugging the cable) can be 10.42.1.1. Given that on B I select the connection to be used only for resource in its network, so there is no default gateway. I tried to take a look at ip route of B and I get:

10.42.0.0/24 dev eno1  proto kernel  scope link  src 10.42.0.1  metric 100 

A address is exactly what field src is, but from the man page it says:

src ADDRESS: the source address to prefer when sending to the destina tions covered by the route prefix.

So to my understanding should be one of the B's interface address, not the "gateway" (A address)...

What am I missing and how can I determine in B the address of A ?

Edit

I'll try to explain what my final goal is. I want to schedule a daily file transfer (with scp) from B to A. However I have very limited physical access to B and no remote access at all, while I have remote access to A. The connection between A and B has the only function to transfer that file, so I don't want A as default gateway (B has also a ppp connection for other services not managed by me) . Basically I want to be free to change A IP in the future without touching B.. So I want to use a bash script to retrieve A IP address.

  • Use different subnets, e.g. 192.168.n.x – ctrl-alt-delor Apr 13 at 15:56
  • Just edited my question, I made confusion with A's ip route command, src is fine and has nothing to do with my question.. – rok Apr 13 at 16:18
  • 1
    I’m missing what your actual goal is. Sharing a connection but without a gateway ? and then knowing the gateway's address ? does not make much sense networking-wise. Do you just want to connect the two computers together ? OR do you need to use computer A as a gateway for B to the Internet and/or to a LAN with different network address ? OR do you perhaps need to use computer A to let B access a wider LAN (i.e. a bridge) ? or what else ? – LL3 Apr 13 at 16:57
  • Edited with more details. Please see if it's clear now.. – rok Apr 13 at 17:20
  • I see. The thing is, since you don’t want computer A being a gateway for B, there’s no gateway to be known. I suppose the easiest approach for your case could be: 1. set your computer B’s dedicated interface to “addresses only” so that it won’t pollute the PPP’s DNS configuration and 2. query either the NetworkManager or the DHCP client process that handles computer B’s dedicated interface to get the DHCP server address, because that should always be computer A’s “shared connection”’s address. – LL3 Apr 13 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.