2

I want to print DNS log into a file. However, my server time zone is GMT +7 and I'm not allowed to change its time zone to UTC.

Could we configure the DNS (ISC BIND 9.10.x) to use the UTC Time zone, instead of local system time zone?

logging {
  channel simple_log {
  file "/var/log/named/bind.log" versions 3 size 5m;
  severity warning;
  print-time yes;
  print-severity yes;
  print-category yes;
 };
category default{
  simple_log;
 };
};

Update:

From @GauravKansal comment, I can make the DNS uses the UTC time zone by running it in chroot environment. It might be not a best solution but it at least can help.

When running the DNS in chroot environment, it can not get the local system timezone. Then it will use the UTC as default.

6
  • Are you running bind in chroot environment ? Oct 19, 2016 at 17:14
  • No, I'm not. But I could try. Will this help to resolve the issue?
    – Tuan
    Oct 20, 2016 at 2:43
  • 1
    I faced nearly similar issue two years back. I was running bind in chroot environment and logs was getting timestamped as per UTC although local time was set in the system. This was happening because configuration inside chroot jail was not able to access timezone settings. I don't think this will be a best approach but till the time you didn't get a better solution, you can try this. Oct 20, 2016 at 3:31
  • Thanks @GauravKansal. I can deal with the UTC time zone by running named in chroot. It might be not a best solution but it can help me.
    – Tuan
    Oct 21, 2016 at 2:51
  • Did you get any solution ? Oct 29, 2016 at 15:45

1 Answer 1

1

Copy cp /etc/localtime /var/lib/named/etc/localtime

Change paths depending your chroot enviroment Should fix your problem

5
  • As the comments and the edit already has this solution, you should explain more carefully how this exactly improves the current state and how it solves the problems faced before. Jun 8, 2017 at 10:36
  • If you read carefully there is no solution posted: "No, I didn't. I'm using the chroot now". The above provides a solution inside a chroot enviroment
    – amprantino
    Jun 9, 2017 at 17:39
  • As the chroot environment doesn't see /etc/localtime it falls back to UTC, which is the workaround here. Copying it to /var/lib/named/etc/localtime repeats the problem, thus not a solution. Jun 9, 2017 at 17:42
  • Bind9 has access only to the chroot environment. Therefore /var/lib/named/etc/localtime means /etc/localtime for bind9. I assume that chroot enviroment is "/var/lib/named/" Copying the file inside the chroot environment it does solve the problem. At least it did for me. Thus I posted the solution here.
    – amprantino
    Jun 16, 2017 at 19:24
  • Yes, but OP had the opposite problem and the chroot environment was the solution for it. Jun 16, 2017 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .