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.

  • Are you running bind in chroot environment ? – Gaurav Kansal Oct 19 '16 at 17:14
  • No, I'm not. But I could try. Will this help to resolve the issue? – Tuan Oct 20 '16 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. – Gaurav Kansal Oct 20 '16 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 '16 at 2:51
  • Did you get any solution ? – Gaurav Kansal Oct 29 '16 at 15:45
1

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

Change paths depending your chroot enviroment Should fix your problem

  • 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. – Esa Jokinen Jun 8 '17 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 '17 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. – Esa Jokinen Jun 9 '17 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 '17 at 19:24
  • Yes, but OP had the opposite problem and the chroot environment was the solution for it. – Esa Jokinen Jun 16 '17 at 19:43

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.