Right IP Address?

Just noticed that the IP address in the administration page for both the MySQL (127.0.0.1) and EmonCMS (127.0.0.1) servers is incorrect. The Pi's static IP address is a 192.x.x.x address. The MQTT address is correct. Version9.2 | 2015.11.27.

Is this by design?

pb66's picture

Re: Right IP Address?

127.0.0.1 is the IP address for "localhost", If you send something to "127.0.0.1" it doesn't leave the machine, if you send something to 192.x.x.x from the same machine, it will go to the LAN router and be sent back again, so you are dependent on a working LAN connection even for an internal delivery unless the IP is recognized as it's own IP, it is an absolute ref rather than relative to itself, similar to using "./" for current directory rather than a full (absolute) address. This removes the need for it to know who or where it is.

Paul 

dBC's picture

Re: Right IP Address?

Paul, while I agree completely with the gist of your answer, and agree that localhost is the way to go if you want to talk to something on your own machine, it's not true that packets sent to the IP address of a local interface will be sent out onto the wire.  

The mechanism for sending packets back into the stack is usually identical for loopback and local addresses and neither get to the driver, much less the wire.  A simple way to verify that is to flood ping your local address. The stats at the end of the ping will reveal millions of packets sent/received but the interface stats won't have seen/counted any of them (nor will the activity LED on the LAN port).

pb66's picture

Re: Right IP Address?

Thanks for the correction dBC, I've never really looked that closely at the actual route of the 192.x.x.x packets and therefore should really have avoided using it to explain the relative addressing references. It was only intended to give the "gist" but not at the cost of bad info, I hope the amendments are better suited.

Paul

borpin123's picture

Re: Right IP Address?

Hi, Paul,

Yes I fully understand local host etc.  I believe that both the 127 and the 198 range of IP addresses perform the same function in that are deemed private i.e. they cannot be routed outside of your local network and will never have a DNS entry (outside of a local network).

My point is that the information on the admin screen is actually meaningless if it is mean to help the administrator know, for instance, the IP address of the machine it is running on.  It is also not consistent as the MQTT reports the static IP address of the machine. Actually knowing where it is might be useful.

Cheers

pb66's picture

Re: Right IP Address?

You are right, the MQTT isn't consistent with the rest, ideally all of them should default to 127.0.0.1 and then edited if required, This could be on a second machine which connects to a LAN's single MQTT broker on the first machine, whilst mySQL is located on a NAS elsewhere, so they could all be different, but by default it should be assumed to be all on one "this" machine and not need the IP to be set.

And yes it would be good to see the machines IP address whether fixed or dchp, and also the "external" IP via a ping would be good too. 

Paul

dBC's picture

Re: Right IP Address?

if you send something to 192.x.x.x from the same machine, it will go to the LAN router

Well, at the risk of dragging this thread well off topic... but if you really want an IP routing lesson ;-)....

If a packet is destined for another host on the same subnet, i.e. another 192.168.1.x (say) address, then it won't go to the router, but rather directly to that host.  All machines on a subnet can talk to each other directly, and the router won't see that traffic at all.  A host will only send a packet to the router if it doesn't have its own path to that host.

So in a simple residential environment with lots of hosts on one 192.168.1.x/255.255.255.0 subnet say, all hosts will chat to each other directly, and only send packets to the router when they're destined for the outside world.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.