Why did the output of “hostname -I” change when using the same PC?

152
September 15, 2018, at 09:40 AM

I'm creating an android app that connects to a local node.js server using socket.io.

I use hostname -I, ifconfig, and ip addr show to find my computer's IP address.

I did these commands earlier today and I saw that my IP address was 192.168.1.xx. I created a socket and was able to successfully connect my android app to my local server.

Now a few hours later, I test the android app and it no longer connects. I ran the commands again (snapshots below) and the output of the three commands i used to find my ip address are now different... the output points towards my IP address being 172.21.37.xxx.

Can the output of the three above commands change? I'm using the same machine, I don't know if this is relevant but I tri-booted my PC (I have Windows 10, Ubuntu 18, and Mint 18). I did move location, I'm using my library's public wifi.

Any information, including links to understanding more about how these commands work, would be very appreciated. I can post more info on request. If I find any new information I'll update the post.

hostname -I:

ifconfig:

ip addr show:

And as always, thanks for reading!

Answer 1

Jeffrey said this first ^

If you moved location, it’s possible that your computer connected to a different router hosting your library’s wifi network. By using multiple routers like this, you can appear to cover a large area and have clients only have to connect to one network. Your device then should connect to the nearest source of that main network.

My guess is that by moving, your computer connected to a different router and was assigned a new local IP. If you stay in the same area this may not happen.

Rent Charter Buses Company
READ ALSO
Compare Fabric App Distribution and the Google Play Store Test Channel?

Compare Fabric App Distribution and the Google Play Store Test Channel?

What reason would I use Fabric App Distribution instead of the Google Play Store Test Channel to deploy my Android app to testers, if I will not be using it for the equivalent iOS app?

153
How to use aar library in Eclipse ADT

How to use aar library in Eclipse ADT

I'm using Eclipse with ADT plugin to develop Android applications and I need to use some aar libraries but the ADT doesn't support this type of libraries so my question is : How can I use aar libraries in Eclipse like Android Studio?

263
Creating transparent Forms (or Activities?) in Firemonkey Delphi for Android

Creating transparent Forms (or Activities?) in Firemonkey Delphi for Android

I want to create a transparent activity (or should I call it Form?) in Delphi (FMX) for Android, like this user does in his video

201
How to connect spinner items with data

How to connect spinner items with data

I'm trying to build an Android app for car serviceI put a spinner with items such as "oil change" etc

160