6

I'm working through some tutorials for setting ntpd clock from gpsd. The guides that I'm working from list adding something like this:

server 127.127.46.0 
fudge 127.127.46.0 time1 0.0 time2 0.0 refid GPS

to /etc/ntp.conf however every tutorial seems to use a different ip e.g. 127.127.28.0 or 127.127.40.0 etc.

What do these addresses correspond to, and how can I find out the correct one to use?

13

It seems that the loopback ip-address range 127.127.0.0/16 is used by NTPD to represent drivers for specific clocks. The third octet is the number of the specific driver as found on the list of drivers here and should probably correspond to either your actual clock or to how you want to interact with gpsd.

The fourth octet is the "unit number", which was originally meant to be used in case there were multiple devices on a system supported by the same driver, although in some cases it gets used differently.

As far as I can tell no driver actually connects over TCP/IP to that loopback address, it appears a NTPD quirk to name/represent drivers as loopback ip-addresses.

The pseudo IP-address 127.127.28.0 therefore indicates a specific driver in NTPD, specifically driver 28, the shared memory driver SHM and is one way gpsd and ntpd can interact.

127.127.46.0 denotes a different driver, driver 46, the GPSD NG client driver a specific client driver to interact with gpsd.

  • 2
    Correct. The fourth octet is the "unit number", which was originally meant to be used in case there were multiple devices on a system supported by the same driver, although in some cases it gets used differently. In the case of driver 46, 127.127.46.x instructs gpsd to open /dev/gpsx, which serves the original purpose, but the high bit is overloaded for a special purpose. – hobbs Mar 29 '16 at 18:27
4

All IPv4 addresses in the 127/8 netblock are reserved for host loopback. However, only 127.0.0.1 is commonly used.

RFC 5735, section 3.

127.0.0.0/8 - This block is assigned for use as the Internet host loopback address. A datagram sent by a higher-level protocol to an address anywhere within this block loops back inside the host. This is ordinarily implemented using only 127.0.0.1/32 for loopback. As described in [RFC1122], Section 3.2.1.3, addresses within the entire 127.0.0.0/8 block do not legitimately appear on any network anywhere.

Having different addresses used for different purposes when all addresses end up in the same place is useful:

  • for traffic separation e.g. in firewall rules
  • for any services that do not support virtual hosting

Generally speaking, as long as your system routing tables are set up to allow for 127/8 as loopback, you can use any 127/8 address you want, as long as you are consistent on the server and client sides.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.