[ntp:questions] Regarding updation of IP addresses in the ntpd.conf file

unruh unruh at invalid.ca
Thu Jul 19 16:56:17 UTC 2012


On 2012-07-19, Arpith Nayak <arpithnayak at gmail.com> wrote:
> Hi all,
>    As one member pointed out, YaST does seem like a good place to start
> looking. However it still doesn't answer my question. I know there is just
> one system clock in a machine. I want to give the user the ability to
> choose which NTP server his machine sync's with.
>
>     Why do I want to give the user that functionality? It is because I'm
> working with a secondary processor with embedded linux which independently
> keeps time and its uses a different frequency timer than the timer of the
> host machine (assume the host machine is running a NTP server for me to
> sync with using its IP address as well). So there is an offset occuring in
> the timing as time goes by and needs to be periodically updated/synced. So
> by letting the user choose the server he wants his machine to sync with I'm
> basically giving him functionality to set his local clock properly in the
> secondary processor. (i.e. local machine time when he is offline, using the
> host machine, and the network clock when he is on the network.)
>
>    The problem doesn't lie in whether I'm able to read ASCII data into my
> program. That would be pretty straightforward. What I can't seem to figure
> out are the constraints applied on the server addresses used in the .conf
> file.
> e.g. suppose i was to say my NTP server is at:
> xxxxx.yyyy.zzzz.wwww.xxx.yyy.zzzz.......(yes-its-a-really-deep-situated-server-with-a-long-alphanumeric-hostname/DNS-address)...xxxx.yyyy.zzzz
> as the server name would ntpd take it? If not what is the limit for the
> variables that are used to write and read addresses from the .conf file?

No idea what that means. Are those numeric addresses or text based
addresses? You could always put the possible server ip addresses with
short nicknames into /etc/hosts and tell those secondary processors to
use host based name resolution. 

Also, you can tell ntpd to use a different .conf file 
man ntpd
look for the -c option
so on the subsidulary processer put in a different .conf file, and a
different drift file (look for the -f option).

Put in the host name as one of the ntpd servers, with a higher stratum,
so when the network hosts come online, they will tend to be picked
first. 


>
>     The servers are normally controlled by /etc/ntp.conf file. I however
> want to keep my drift file in a different location which will be specified
> in the .conf file during build-time. I do not want to use a system call to

put them into the ntpd startup command. 

> specify this in the secondary processor. So if I'm doing a raw write of the

??

> drift file's location into the .conf file are there any rules I should be
> aware of?
>
>     Yes, you are right: I will be using the lines starting with server to
> read the addresses. But how do I determine the end of the address? (Is
> there a "\n" newline character appearing at the end of each line in the
> .conf file? Will I be breaking any rules in ntpd by using "\n" to mark the

Yes, there is a \n terminating the lines. 

Make sure you respect the # characters. (man ntp.conf)


> end of the IP/hostname address if I can even use it that way?)
>
>     I really do not understand what you mean by a
> vision/understanding/editing thing (wait, is this non-understanding another
> instance of your query? :-p )

Yes. I did not understand what you meant by "how I can read". To read is
to look at squiggles on paper or on a screen and interpret them. If you
are blind, you cannot read them (a vision thing) If you cannot interpret
them you cannot read them (and understanding thing). Or " read" may be
being used as a metaphore for having a computer program edit the file. 


>
>     The user is the person who will (hopefully) use my program (and not try
> to kill me after using it). He will be presented with a CLI to see which
> servers his machine is synced to via the machine's IP and I want to let him
> specify which IP the machine  should sync with. And keeping aside the

Why should he have to try to figure that out? Just give him a bunch of
pool servers and the main processor as servers, and let ntp handle it. 


> argument that letting users specify NTP server IP that could lead to
> mayhem, let's just assume here that the users are system admins
> (OS-agnostic) who know a thing or two about NTP servers and want to connect
> to servers at various strata levels based on their requirements. The linux
> shell is hidden from them at all times. (I guess that is why I am writing
> this API)

But ntpd does a good job of determining which sources it should use. And
if they are "sysadmin" types, editing a separate .conf file should be
easy for them. 


>
> Thanks again and regards,
>
> Arpith
>
>
> On 2012-07-18, Arpith Nayak <arpithnayak at gmail.com> wrote:
>> Hello to all you mighty programmers, hackers and USENET members,
>>
>>    I am trying to implement an API for ntpd by which the user can specify
>> which servers he wants his machine to update time from. The application
>
> There is just one system clock, so having various users trying to update
> the time is a recipie for disaster. On the other hand  you may mean that
> each user has their own physical machine, and wants to control that. If
> you are talking about multiple users on one machine ( even if they
> are using VM) then you want only one version of ntp running controlling the
> machine. Perhaps if you told us what problem you are trying to solve,
> rather than asking us about your imagined solution, you might get better
> advice.
>
>
> The servers are controlled by /etc/ntp.conf file (Or are you using
> windows?)
>
>> however uses a single .conf file. Are there any limits specified for the
>> addresses that can be given in the .conf file? Also could you please help
>
> What did you have in mind?
> The lines starting with "server" are the ones that specify which servers
> the system uses.
>
>> me out as to how I can read the IP addresses already present in the .conf
>
> What do you mean "how I can read"? Is this a vision thing, an
> understanding thing, and editing thing?
>
>> file and how to update these values based on the user's choice? I'm also a
>
> Why would you want to? And who is this "user"?
>
>
>> novice to programming, so could you please help me out by not making your
>> answers too technical?
>
> Again. what do you hope to accomplish?



More information about the questions mailing list