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