Stories
Slash Boxes
Comments

News for nerds, stuff that matters

Slashdot Log In

Log In

Create Account  |  Retrieve Password

Time Syncing Through a Firewall Without NTP?

Posted by Cliff on Sat Jul 30, 2005 05:54 PM
from the route-around-the-problem dept.
dvdsmith asks: "Say are dealing with a Windows network that for internet access must pass through a firewall that you have no control over. Said firewall apparently blocks the known time protocols (NTP,daytime,etc) and you know from experience that those who control it will not allow any exceptions. If one sets up an internal NTP server (Windows XP or 2000 workstation) for all others to sync from, is there another reliable method for updating time on the server, like pulling from a Java website? See the time.gov website as an example. Any ideas?"
+ -
story
This discussion has been archived. No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More
Loading... please wait.
  • by captnitro (160231) * on Saturday July 30 2005, @05:57PM (#13204465)
    Of course, your most important ingredient is this baby right here: the external web service. You can get it in a can but to really do things right, you gotta strangle yourself a fresh one.

    We're going to sync with our outside web service using a simple SOAP client, written in whatever language you prefer, and setting the time. (Your users will get their time from you via NTP still, of course.) This isn't required, but for that fresh BAM! taste, it's recommended. Mind the delay calculations if you're writing the client side of it yourself [php.net], the WWWait will have a little bit more effect here depending on your setup. If you want to make it quick and dirty, there's no reason to go through the SOAP/WSDL hoops, the point is having it on a known port and piggybacking across HTTP's fame and success, and then sleeping with its girlfriend, and stealing her wallet on the way out. BAM!
    • by Anonymous Coward
      Use SOAP XML bloat to get the current time? Jebus. People in this industry are utterly clueless. How about a 10-line daemon in C that sends the current time as a 64-bit value when you connect to it?? Or can't people program any more unless they use SOAP and PHP???
      • You're not going to get a reply that way. Here, let me try:

        We're going to sync with our outside web service using a simple SOAP client,

        A SOAP client? Interesting!

        written in whatever language you prefer, and setting the time. (Your users will get their time from you via NTP still, of course.) This isn't required, but for that fresh BAM! taste, it's recommended. Mind the delay calculations if you're writing the client side of it yourself [php.net], the WWWait will have a little bit more effect h

      • amen, rdate still works as well now as ever. Trivial server to run too, no security breaches
      • And what port is that C daemon going to listen on? Port 80? What if that is proxied? The only thing that is certain to get through is HTTP traffic.

        I'd go for a much simpler approach. It depends on how accurate this needs to be, but find a web server with accurate time (Perhaps a friend has webspace or a dedicated server, or even a home DSL/Cable connection), and put a one-line PHP, Perl, anything, script on it that simply sends the timestamp. Perhaps try to speed things up marginally by removing all but the
    • You don't want to make a new SOAP service and have to do all the delay calculations.

      If you have access to an external server, just tunnel NTP over HTTP. (http://htun.runslinux.net/docs.html [runslinux.net])

      Essentially no programming required.

      It might be slighly less accurate than your way, but only if the time on the existing server really is hyperaccurate.

      (That is, SOAP directly to an authoritative time server is probably more accurate than a tunneling proxy, but a tunneling proxy is probably more accurate than the two s
  • by Anonymous Coward on Saturday July 30 2005, @06:09PM (#13204509)
    Ask the morons in charge of the firewall to please open the NTP port and take the time to explain why this is important.
    Take it up with management if said morons disagree.
    • The guy already said, "It's impossible to change the firewall." You can't answer that by saying, "Change the firewall."
    • He has good reason to be very afraid of the "morons", as you, brave Mr. AC, have so cavalierly stated.

      Remember - Do not meddle in the affairs of wizards, for you are crunchy and taste good with ketchup.

      Simon

      • Who is playing the political games? IT does what the boss tells them to. If you are a typical slashdotter you do not play the political games well. So you should have your boss play them for you, that is his job. Just tell your boss that you need good time, and let him do it.

        If you boss won't play those games, think about sending thing up the line. Start asking questions in the company meetings about why IT isn't responding to employee needs. Your point will get across. (Careful here though, thi

      • by ColaMan (37550) on Saturday July 30 2005, @09:23PM (#13205300) Homepage Journal
        Get quotes for your time-sync hardware, and a *formal* quote from IT. (if no formal quote is forthcoming, keep your evidence of attempting to obtain one, and do a best-guess yourself, factoring labour/bandwidth/etc).

        Go up the chain to whoever manages both the IT and your division. Say "We need time sync for such-and-such. It's necessary."

        Give them a breakdown of costs like so:

        $x for GPS stabilised NTP appliance.
        $y for some bonehead in IT to open the port up.

        Make sure you put the expensive one first. If it costs the IT department more to poke a hole in the firewall, well, hell, you'll get a new toy to play with. But most likely management will say (paraphrased) "WTF? Bring me the head of the IT department manager, on a silver platter."

        IT departments are there to provide services for the rest of the company. That's their job. If they're not doing their job, call them on it. They're just a lead weight around the company's neck otherwise.
        • by secolactico (519805) on Saturday July 30 2005, @10:36PM (#13205604) Journal
          Give them a breakdown of costs like so:

          $x for GPS stabilised NTP appliance.
          $y for some bonehead in IT to open the port up.


          And don't forget to include installation costs in the breakdown. Depending on your building infrastructure, you might have to run wiring for an external gps antenna, plus related costs of mounting an outdoor equipment, which will probably be done by the maintenance people or subcontracted.
      • lack of FTP access

        Well, any techie worth their salt shouldn't consider FTP except in very special cases. Plaintext passwords is a huge security hole in the security models at most businesses.

        I always encourage use of SFTP instead. However, most developers seem scared of SFTP for some reason. It's pretty much the same darn thing.

        And I always allow NTP :)
      • Slick, that turns the problem around and drops it in their lap. Providing reliable network time would certainly be their job (especially if they block access to outside servers), and it would be easy to show that it's a requirement for network operation and logging. (OP might want to jury rig something to periodically test their time for accuracy.)
  • Tunnel. (Score:5, Informative)

    by SharpFang (651121) on Saturday July 30 2005, @06:10PM (#13204514) Homepage Journal
    Set up a host outside the firewall, and tunnel the NTP data over some "allowed" port, so it gets through. Or set it up as NTP server on non-standard port (80?) outside the firewall.
    If you want precise measurement, this is the way to go. NTP software will correct the latency errors, no matter if you have direct connection or if it goes through tunnels around the globe, so you have precise time. But if you go for methods like reading time from website applet, all the network latency problems get completely neglected and just add up to the error of the internal server. You could just as well sync it to your hand watch instead.
  • radio (Score:4, Interesting)

    by Fëanáro (130986) on Saturday July 30 2005, @06:11PM (#13204518)
    you could build a device that gets the time via radio (LINK [buzzard.me.uk]) or buy one that does this (like a gps receiver?).

    or if any udp port is open in the firewall, set up a ntp server outside that answers on that port
    • Re:radio (Score:4, Insightful)

      by samjam (256347) on Saturday July 30 2005, @06:41PM (#13204687) Homepage Journal
      I like this idea.

      First get a written refusal in response to a written request to open NTP on the firewall.

      Then use this to justify a hardware purchase for the clock hardware.

      Wait till bosses realise that a $500 piece of kit and a couple of days setting up could be replaced by 5 mins configuration by a dolt.

      Sam
      • Wait till bosses realise that a $500 piece of kit and a couple of days setting up could be replaced by 5 mins configuration by a dolt.
        You sure about that? My boss told me to buy a switch so that I could have additional ports in my cube (I have 2 and need 2, but one is used by the workgroup printer), as opposed to having someone move the printer 6 feet to hook up to an unused second port in another cube - or just get a longer LAN cable.
        • Well, that makes sense.

          You are already feeling the pinch of the scarcity of switch ports, juggling them around isn't a long term solution and one day the pinch will be very inconvenient.

          Better get a new switch now before it gets urgent instead of afterwards.

          The expense will be offset against the convenience now and the lack of severe inconvenience in the future.

          Sam
          • No, he wants a small switch (actually, he asked that I purchase a "router" complete with a WAP built in, even though the company doesn't support wireless networks and it'd be a big security problem if left open) just in my cube to serve only me. I'm one of a very few people who have a second computer, so the idle LAN drops in the other 90% of cubes (yes, they wired 2 for each cube, but don't use them) are going to remain idle for a very, very long time.
  • The most common solution to a firewall blocking a particular port or service: tunnel it. SSH is probably the easiest form of tunneling and putty has a great command line utility for just that. But you can also tunnel over HTTP using some basic programming skills. Worst case: set up a port forwarder on the outside of the network that forwards requests on port 80 to time.gov (or some other trusted NTP server) then set your internal NTP server to sync with it on port 80. (This assumes, of course, port based fi
      • I have written dozens of systems taking advantage of UDP and TCP based on the need of the system. I absolutely do know the difference. I haven't, however, had any reason to learn the underpinnings of the NTP protocol as yet, so you're right in that I didn't bother to look up whether its UDP or TCP based. UDP can be tunneled as well, and the idea is still valid. Maybe they allow UDP for some other application (video conferencing etc.) and you could always just use that port with a known outside source. Think
      • How exactly would this work? If they're blocking UDP/123, why wouldn't they also be blocking UDP/80?

        A friend of mine wrote a userspace application that allowed him shell access to a remote system when he was behind a gestapo firewall that not only restricted you to TCP/80, but it also further restricted you to HTTP.

        He "simply" tunneled the shell commands and response thru HTTP packets. He figured he could forward just about anything else similarly.
  • 1. Hook up a GPS receiver directly, via the usb/serial port, use whatever software [google.co.uk] to interface

    2. Use HTP: HTTP Time Protocol [clevervest.com]

  • You should use NTP (Score:5, Insightful)

    by Anonymous Coward on Saturday July 30 2005, @06:40PM (#13204684)
    Correct subsecond time is important.

    If your boxes are hacked and you go into court and you can't demonstrate that your log timestamps have anything to do with reality, you might not be able to use them as evidence.

    You also would like to be able to accurately judge HTTP cache timeouts and other time-sensitive things.

    You also don't want your time to "step" (jump by more than one second) if you can help it. It screws up sensitive daemons and I've seen more than one box crash and burn and start spawning crap when the clock jumped backwards.

    Have them open up the damn firewall, set up a reliable Unix-based NTP server on the inside that syncs to something outside, and have the workstations sync up with that.

    You CANNOT tunnel NTP over SSH. NTP uses UDP.

    You also don't want to just get the time from some web page and set the clock because your clock may jump, and you don't adjust for latency correctly either (NTP is *complicated* because there are a lot of edge cases and complex concepts here). Also you'd like to be able to select from multiple sources and throw out any outliers, in case one has been hacked.

    If you can't do the sane thing, which is open up the firewall, you can just set up a local Unix NTP server and at least your boxes will all have the same time as that box, even if it's the "wrong" time.

    You can also use GPS or a dialup modem to set the time on your NTP server.

    To recap:

    1) set up a centralized NTP server
    2) sync to that NTP server
    3) if possible, sync that NTP server to another external NTP server, OR a radio or modem signal.

    It ain't rocket science folks.
    • Hmmm, curious, I thought you could tunnel IP over SSH. It doesn't matter what what NTP uses as transport for it. It should tunnel. Now, it might screw up the protocol. However, the protocol should just treat the tunnel as a UDP connection with fairly odd properties.

      Kirby

        • You really shouldn't be so absolute about those things. I've done IP over ssh, which means you can do ICMP, UDP, and TCP over it. Not using ssh and port forwarding, but using ssh, pppd, it can be done. You create a pppd device that is attached to a terminal, the terminal gets created by sshd. You do all the same things at the other end. It's a bit more work on both ends to accomplish it, but anywhere you can do ssh port forwarding, you should be able to tunnel PPP over SSH.

          It's standard and fairly si

  • "Atomic Clock" card (Score:5, Informative)

    by SA Stevens (862201) on Saturday July 30 2005, @06:57PM (#13204767)
    You can run a local NTP server, and install an 'Atomic Clock' receiver in it, on a Card. Basically it's a 10 MHz WWV receiver that decodes the time info and reads it into the PC. They've been around a long time.
    • This has got to be the easiest suggestion someone has said. Not only are you avoiding potential NTP exploits in the network, you are also not going head to head with your boss. The solution is likely extremely cost effective, easy to implement, and relatively pain free. It solves all of his problems and very elegantly too. Sir, you deserve to be modded up, but for some reason, I have not seen modpoints for months now. What's going on with that? I tried metamoderating 20 times in a row and still no modpoints
    • Have you checked the obvious? Many routers and firewalls also serve NTP. Try polling NTP on the firewall. It just might work.

      If that doesn't work, try polling the local router. Try polling a remote router that's still inside the firewall.

      A customer of mine has several sites, and the sites are linked through frame relay (or is it T-1?). The firewall blocks port 123, so NTP with the outside world is (generally) out of the question. However, the frame provider is MCI, who also happens to manage the routers for
  • Synced with what? (Score:4, Interesting)

    by spaceyhackerlady (462530) on Saturday July 30 2005, @11:48PM (#13205890)

    Do the systems need to be synced to the outside world, or merely consistent with each other?

    If the silly firewall people won't help you (you might remind them that you do in fact work for the same company...), you need to set up your own NTP server. Either a real one with a GPS receiver, or a pretend one that everybody can follow and have the same time, regardless of what that time actually is (see initial question).

    The occasional phone call to the NIST's dialup time server [nist.gov] might be useful too.

    ...laura

  • Companies make GPS-timeclock receivers that connect to your server with a serial cable and have software to do clock drift adjustment. If you can get a GPS signal, you're set.
  • HTPdate [clevervest.com] would seem to be what you're after here.

    There's a perl implementation that will work on Windows machines.

  • Most webservers return the date in the HTTP headers.

    For example, try:
    curl --head http://www.google.com/ [google.com]
  • Try NIST.pl [freshmeat.net]
  • Use a cheap GPS (Score:3, Informative)

    by Telecommando (513768) on Sunday July 31 2005, @11:43AM (#13208177)
    Buy a Delorme Tripmate on Ebay. Buy or build a power/serial cable. Connect pins 2&3 on the serial port so the Tripmate will self start. Parse the ASCII strings sent by the Tripmate. The string you need looks like this:

    $GPRMC,HHMMSS,A,LATITUDE,N/S,LONGITUDE,E/W,SPEED,D IRECTION,DDMMYY,MAGNETIC,E/W*CHECKSUM

    A search on Google for "Delorme Tripmate" and/or "NMEA-0183" should turn up plenty of info.

    I use a Tripmate in my car connected to a Microchip PIC and an LCD to display time, date, location, speed and direction.

  • Why not ask the firewall people if they have an NTP source you can use? If they don't, ask them to set one up for you that way they don't have to open their firewalls to your NTP needs.
  • I have a cheap Hauppauge WinTV card and I sometimes use alevt-date in linux to set clock. I've setup a script that sets clocks on 3 other computers aswell through ssh.
  • I understand the extreme paranoia of a firewall admin, especially if there are large numbers of windoze machines on her network. There may be a touch of tin-foil hat syndrome from rumours that windoze machines report activation codes encoded in SNTP requests to time.windows.com. If you are on a government network, then some security dudes have already demo'd tunneling secret info over NTP UDP [doxpara.com] packets, resulting in your properly locked down windoze network. There really is no reason a windoze machine needs t
  • Hardware boxes (Score:3, Interesting)

    by wcdw (179126) on Monday August 01 2005, @02:16PM (#13216440) Homepage
    This is not what the submitter wanted to know. However, for all of you who have proposed hardware GPS-based solutions, you might want to note that there are also companies making similar hardware which get their time signal from the CDMA cellphone signals.

    CDMA in turn gets its time from GPS, but is far easier to receive in most locations - no need to run an antenna cable up to the roof. They also tend to be cheaper.
    • Re:too easy (Score:2, Interesting)

      by Anonymous Coward
      Just write a batch file or shell script to get the time from any website that shows the current time of refresh on a page.

      How about
      $ wget --spider -S $WEBSITE 2>&1 | grep -i 'date:'
      No need to parse the HTML, just use standard HTTP headers.
      • BAD idea! Don't do that!

        Think of it for a while. The HTTP server takes its local date, writes it into a socket, and sends it to you. By the time you get it, the time will have changed. If your time was actually right, it'll go like this:

        You (10:00:00): HTTP request
        Server (10:00:01): Sends date
        You: (10:00:02): Date received, set

        And here you set the date backwards in time, which is definitely going to cause problems.