Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have doubt how iptables keep changing the info in iptables when timezone is change. I am using iptables s v 1.4.8

I have blocked one IP with following details

 # date
    Thu Jun 6 12:46:42 IST 2013

#iptables -A INPUT -s 10.0.3.128 -m time --datestart 2013-6-6T12:0:00 --datestop 2013-6-6T13:0:00 -j DROP

# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 10.0.3.128 anywhere TIME starting from 2013-06-06 12:00:00 until date 2013-06-06 13:00:00

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

But after I change the timezone following things happened automatically .

AFTER TIME ZONE CHANGE +++++++++++++++++++++++

#date
Thu Jun 6 15:17:48 HKT 2013

# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
DROP all -- 10.0.3.128 anywhere TIME starting from 2013-06-06 14:30:00 until date 2013-06-06 15:30:00

Chain FORWARD (policy ACCEPT)
target prot opt source destination

Chain OUTPUT (policy ACCEPT)
target prot opt source destination
#

The time value is changed in the rule . It is changing with the timezone how. Where iptables keeps track of timezone.

Kindly explain me.

share|improve this question

migrated from stackoverflow.com Jun 25 '13 at 10:00

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

up vote 3 down vote accepted

It's not keeping track of anything. It converted the strings 2013-6-6T12:0:00 and 2013-6-6T13:0:00 to raw time_t when you added the rule, using the timezone that you had set up at that time. Then later when you run the -L, it converts that timestamp back to a readable string using the new current timezone.

The timezone information that was implicit in your initial command was lost immediately after it was done executing, and every execution of iptables -L attempts to reconstruct the original time string by applying the current timezone to the time_t.

share|improve this answer
    
Thanks for the answer, I guess you definitely gone through the code of iptables.What I got form your reply every time we are giving the iptables -L it will show the time as converted to local timezone.One doubt here is where this information is stored ,as you told "every execution of iptables -L attempts to reconstruct the original time string by applying the current timezone to the time_t" , but where this "original time string" is coming to the code(If rebooted then how it is retaining) .Is there any buffer where the iptables is storing the data or any file in the linux . –  pradipta Jun 6 '13 at 10:52
    
The time_t is stored in the kernel. The strings are not stored anywhere. iptables rules do not persist across reboot. The command has to be run again after every reboot to put the rule back into the kernel's memory. –  Wumpus Q. Wumbley Jun 6 '13 at 20:36
    
Thanks ,It means each time we are giving any time range it will store in kernel buffer and when we are giving the iptables -L then this time is referred and it is changed to string with respect to local time zone. am I correct ? –  pradipta Jun 7 '13 at 9:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.