Discussion:
where do I find the NTP server address with 'dhcpc -O ntpsrv'
Lambrecht Jürgen
14 years ago
Permalink
Hello,

The NTP server ip is distributed via DHCP in my case.
So I want to do 'ntpd -p $NTP_SERVER'.
But that variable $NTP_SERVER is empty, and also /etc/ntp.conf does not
exist.

Does anybody know where to find the NTP server's IP address received
with 'dhcpc -O ntpsrc' ?

Regards,
J?rgen

P.S.: when I try to search the mailing list on busybox.net, google gives
an error that the site may be sending spam..
--
J?rgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045 Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk
Laurent Bercot
14 years ago
Permalink
Post by Lambrecht Jürgen
The NTP server ip is distributed via DHCP in my case.
So I want to do 'ntpd -p $NTP_SERVER'.
But that variable $NTP_SERVER is empty, and also /etc/ntp.conf does not
exist.
Does anybody know where to find the NTP server's IP address received
with 'dhcpc -O ntpsrc' ?
If I understand the udhcpc.c code correctly, result of unknown options
listed with "-O foobar" are put into the environment via the line
ofs = sprintf(*curr, "opt%u=", i);

So if you start your client with "udhcpc -O ntpsrv", if my guess is
correct, you should get the NTP server address in the "opt0" environment
variable.
--
Laurent
Lambrecht Jürgen
14 years ago
Permalink
...
thanks for the hint, but 'env | grep -i opt' gives nothing.
I must say, the dhcp server sends out the ntp server IP address by
default, so it is not necessary to ask.
With wireshark, I see the DHCP offer, and it contains the NTP server IP
address.

J?rgen
Post by Laurent Bercot
--
Laurent
--
J?rgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045 Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk
Lambrecht Jürgen
14 years ago
Permalink
...
Indeed, but there are bugs in the code.
For the 256 options, only 32 bits are allocated, and 1<<42 assignments
to an unsigned happen..
I fixed the bugs, and will try today if it works.

J?rgen
Post by Laurent Bercot
--
Laurent
--
J?rgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045 Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk
Denys Vlasenko
14 years ago
Permalink
Post by Laurent Bercot
Post by Lambrecht Jürgen
The NTP server ip is distributed via DHCP in my case.
So I want to do 'ntpd -p $NTP_SERVER'.
But that variable $NTP_SERVER is empty, and also /etc/ntp.conf does not
exist.
Does anybody know where to find the NTP server's IP address received
with 'dhcpc -O ntpsrc' ?
I suppose you meant "ntpsrv".
Post by Laurent Bercot
If I understand the udhcpc.c code correctly, result of unknown options
listed with "-O foobar" are put into the environment via the line
ofs = sprintf(*curr, "opt%u=", i);
But ntpsrv is a *known* option, therefore it is exported as $ntpsrv
environment variable to the udhcpc script, a-la

ntpsrv='10.4.2.125 10.4.5.7'

See examples/var_service/dhcp_if/* for an example.
--
vda
Lambrecht Jürgen
14 years ago
Permalink
Post by Lambrecht Jürgen
Post by Laurent Bercot
Post by Lambrecht Jürgen
The NTP server ip is distributed via DHCP in my case.
So I want to do 'ntpd -p $NTP_SERVER'.
But that variable $NTP_SERVER is empty, and also /etc/ntp.conf
does not
Post by Laurent Bercot
Post by Lambrecht Jürgen
exist.
Does anybody know where to find the NTP server's IP address received
with 'dhcpc -O ntpsrc' ?
I suppose you meant "ntpsrv".
indeed
Post by Lambrecht Jürgen
Post by Laurent Bercot
If I understand the udhcpc.c code correctly, result of unknown options
listed with "-O foobar" are put into the environment via the line
ofs = sprintf(*curr, "opt%u=", i);
But ntpsrv is a *known* option, therefore it is exported as $ntpsrv
indeed, found that out in the mean time..
Post by Lambrecht Jürgen
environment variable to the udhcpc script, a-la
indeed, "to the udhcpc script", and not to the shell environment
variables as I thought wrongly
(http://stackoverflow.com/questions/6981033/why-setenv-does-not-work)
Post by Lambrecht Jürgen
ntpsrv='10.4.2.125 10.4.5.7'
See examples/var_service/dhcp_if/* for an example.
ok, I will check this. Thanks. I thought that the "putenv(..)" code was
useless, and should be removed from dhcpc.c.

Regards,
J?rgen
Post by Lambrecht Jürgen
--
vda
--
J?rgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045 Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk
Lambrecht Jürgen
14 years ago
Permalink
...
In busybox config for dhcp client, you can specify a script, and I
copied the default script and added 'ntpd -P $ntpsrv'.
Thanks,
J?rgen
Post by Lambrecht Jürgen
Regards,
J?rgen
Post by Lambrecht Jürgen
--
vda
--
J?rgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045 Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk
_______________________________________________
busybox mailing list
busybox at busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
Loading...