LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
LinkBack Search this Thread
Old 02-06-2010, 03:00 PM   #1
ScottSmith
LQ Newbie
 
Registered: Mar 2004
Distribution: Debian - Sid
Posts: 22

Rep: Reputation: 1
IPTABLES: Restrict Internet access based on time of day and MAC address


Hello everyone


I am trying to configure my Linux router to restrict Internet access for one computer on my LAN. It needs to be restrictive based on the time of day and the days of the week. I am using the MAC address of the computer to single out the one computer that needs to be blocked. However, this is my first attempt at making any rules with iptables, and I am not sure if I am doing this right. If some one can take a look at this I would greatly appreciate it. This is what I have done so far.

Here is my thinking. Create a new target. Check the MAC address, if it is NOT the offending computer return to the default chain. If it is the offending computer check that we are between the allowed hours and dates and ACCEPT. If we are not within the time/date range then drop the packet.

Code:
iptables -N blocked_access
iptables -A blocked_access -m mac ! --mac-source xx:xx:xx:xx:xx:xx -j RETURN
iptables -A blocked_access -m time --timestart 20:00 --timestop 22:00 --weekdays Sun,Mon,Tue,Wed,Thu --syn -j ACCEPT
iptables -A blocked_access -j DROP
Here I am trying to route all packets regardless of the computer on the LAN into the blocked_access chain for checking.

Code:
iptables -A FORWARD -i eth1 -o eth0 -p tcp  -j blocked_access
iptables -A FORWARD -i eth1 -o eth0 -p udp -j blocked_access
Is it a good idea to route all traffic through the blocked_access chain? I do run other servers that are accessible from the Internet, so I am not sure how this setup will affect that. I also use shorewall on the router to setup iptables for me. How would I integrate this with shorewall?

I am using squid to block access when he is using the web browser. However, he is still able to play games(World of Warcraft) and the like.

I am using Debian sid, iptable(1.4.6), shorewall(4.4.6), kernel 2.6.32-trunk-686.

If there is any other info you need let me know.

Thanks in advance

Scott

Last edited by ScottSmith; 02-06-2010 at 04:04 PM. Reason: corrected iptables options
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-06-2010, 03:47 PM   #2
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14
Posts: 1,554

Rep: Reputation: 89
You can do life of iptables easier, if will check only specific MAC:
iptables -A FORWARD -i eth1 -m mac --mac-source 00:00:00:00:00:01 -j blocked_access
 
2 members found this post helpful.
Old 02-06-2010, 06:37 PM   #3
ScottSmith
LQ Newbie
 
Registered: Mar 2004
Distribution: Debian - Sid
Posts: 22

Original Poster
Rep: Reputation: 1
Thanks nimnull22 for the help

The problem that I have now is that it blocks access regardless of the time. I placed all of the iptables commands into a very simple script file to help changing the timestart and timestop variables. Before I run this script I restart shorewall to clear any other changes that I have made, then I invoke the script with ./blocked_access timestart timestop

Code:
#! /bin/bash

iptables -N blocked_access
iptables -A blocked_access -j LOG --log-level DEBUG --log-prefix 'In BLOCKED_ACCESS: '
iptables -A blocked_access -m time --timestart $1 --timestop $2 --weekdays Sat -j ACCEPT
iptables -A blocked_access -j LOG --log-level DEBUG --log-prefix 'DROPPED MAC: '
iptables -A blocked_access -j DROP

iptables -I FORWARD -i eth1 -m mac --mac-source <MAC_ADDRESS> -j blocked_access
iptables -I FORWARD -j LOG --log-level DEBUG --log-prefix 'In FORWARD chain: '
Here is the output of the blocked_access chain
Code:
Chain blocked_access (1 references)
 pkts bytes target     prot opt in     out     source               destination
   33  1488 LOG        all  --  *      *       0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 7 prefix `In BLOCKED_ACCESS: '
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           TIME from 17:09:00 to 17:11:00 on Sat
   33  1488 LOG        all  --  *      *       0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 7 prefix `DROPPED MAC: '
   33  1488 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0
I noticed that the counters on the ACCEPT line are not increasing; it's as if it is being skipped by iptables.

Here is a snip it from the log file
Code:
Feb  6 17:29:28 router kernel: [157514.443112] In FORWARD chain: IN=eth1 OUT=eth0 SRC=192.168.10.186 DST=74.125.95.106 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=14942 DF PROTO=TCP SPT=1359 DPT=80 WINDOW=65535 RES=0x00 SYN URGP=0
Feb  6 17:29:28 router kernel: [157514.443134] In BLOCKED_ACCESS: IN=eth1 OUT=eth0 SRC=192.168.10.186 DST=74.125.95.106 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=14942 DF PROTO=TCP SPT=1359 DPT=80 WINDOW=65535 RES=0x00 SYN URGP=0
Feb  6 17:29:28 router kernel: [157514.443150] DROPPED MAC: IN=eth1 OUT=eth0 SRC=192.168.10.186 DST=74.125.95.106 LEN=48 TOS=0x00 PREC=0x00 TTL=127 ID=14942 DF PROTO=TCP SPT=1359 DPT=80 WINDOW=65535 RES=0x00 SYN URGP=0
Any suggestions would be greatly appreciated....

Thanks
Scott
 
Old 02-06-2010, 08:21 PM   #4
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14
Posts: 1,554

Rep: Reputation: 89
Can you please send output of: iptables-save

Thank you
 
Old 02-06-2010, 09:33 PM   #5
ScottSmith
LQ Newbie
 
Registered: Mar 2004
Distribution: Debian - Sid
Posts: 22

Original Poster
Rep: Reputation: 1
Here are some snippets of iptables-save:

Code:
-A FORWARD -j LOG --log-prefix "In FORWARD chain: " --log-level 7                                                      
-A FORWARD -i eth1 -m mac --mac-source 00:0D:9D:59:9F:71 -j blocked_access
Code:
-A blocked_access -j LOG --log-prefix "In BLOCKED_ACCESS: " --log-level 7                                              
-A blocked_access -m time --timestart 20:19:00 --timestop 20:22:00 --weekdays Sat  -j ACCEPT                           
-A blocked_access -j LOG --log-prefix "DROPPED MAC: " --log-level 7                                                    
-A blocked_access -j DROP
I attached a full dump

Thanks

Scott
Attached Files
File Type: txt iptables-save.txt (9.3 KB, 7 views)
 
Old 02-06-2010, 09:35 PM   #6
ScottSmith
LQ Newbie
 
Registered: Mar 2004
Distribution: Debian - Sid
Posts: 22

Original Poster
Rep: Reputation: 1
I guess I could just post the whole thing

Code:
# Generated by iptables-save v1.4.6 on Sat Feb  6 20:26:41 2010                         
*raw                                                                                    
:PREROUTING ACCEPT [4917:1260320]                                                       
:OUTPUT ACCEPT [3541:1612287]                                                           
COMMIT                                                                                  
# Completed on Sat Feb  6 20:26:41 2010                                                 
# Generated by iptables-save v1.4.6 on Sat Feb  6 20:26:41 2010                         
*nat                                                                                    
:PREROUTING ACCEPT [893:114255]                                                         
:POSTROUTING ACCEPT [234:15841]                                                         
:OUTPUT ACCEPT [234:15841]                                                              
:UPnP - [0:0]                                                                           
:dnat - [0:0]                                                                           
:eth0_masq - [0:0]                                                                      
:loc_dnat - [0:0]                                                                       
:net_dnat - [0:0]                                                                       
-A PREROUTING -i eth0 -j UPnP                                                           
-A PREROUTING -j dnat                                                                   
-A POSTROUTING -o eth0 -j eth0_masq                                                     
-A dnat -i eth0 -j net_dnat                                                             
-A dnat -i eth1 -j loc_dnat                                                             
-A eth0_masq -s 192.168.10.0/24 -j MASQUERADE                                           
-A loc_dnat -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128                        
-A net_dnat -p tcp -m tcp --dport 6881:6999 -m comment --comment "BitTorrent32" -j DNAT --to-destination 
-A net_dnat -p udp -m udp --dport 6881 -m comment --comment "BitTorrent32" -j DNAT --to-destination      
-A net_dnat -p tcp -m tcp --dport 80 -m comment --comment "HTTP" -j DNAT --to-destination                
-A net_dnat -p tcp -m tcp --dport 443 -m comment --comment "HTTPS" -j DNAT --to-destination              
-A net_dnat -p tcp -m tcp --dport 25 -m comment --comment "SMTP" -j DNAT --to-destination                
COMMIT                                                                                                   
# Completed on Sat Feb  6 20:26:41 2010                                                                  
# Generated by iptables-save v1.4.6 on Sat Feb  6 20:26:41 2010                                          
*mangle                                                                                                  
:PREROUTING ACCEPT [4917:1260320]                                                                        
:INPUT ACCEPT [3898:1072771]                                                                             
:FORWARD ACCEPT [1019:187549]                                                                            
:OUTPUT ACCEPT [3541:1612287]                                                                            
:POSTROUTING ACCEPT [4555:1799556]                                                                       
:tcfor - [0:0]                                                                                           
:tcout - [0:0]                                                                                           
:tcpost - [0:0]                                                                                          
:tcpre - [0:0]                                                                                           
-A PREROUTING -j tcpre                                                                                   
-A FORWARD -j MARK --set-xmark 0x0/0xffffffff                                                            
-A FORWARD -j tcfor                                                                                      
-A OUTPUT -j tcout                                                                                       
-A POSTROUTING -j tcpost                                                                                 
COMMIT                                                                                                   
# Completed on Sat Feb  6 20:26:41 2010                                                                  
# Generated by iptables-save v1.4.6 on Sat Feb  6 20:26:41 2010                                          
*filter                                                                                                  
:INPUT DROP [0:0]                                                                                        
:FORWARD DROP [0:0]                                                                                      
:OUTPUT DROP [0:0]                                                                                       
:Drop - [0:0]                                                                                            
:Reject - [0:0]                                                                                          
:blocked_access - [0:0]                                                                                  
:dropBcast - [0:0]                                                                                       
:dropInvalid - [0:0]                                                                                     
:dropNotSyn - [0:0]                                                                                      
:dynamic - [0:0]                                                                                         
:fw2loc - [0:0]                                                                                          
:fw2net - [0:0]                                                                                          
:loc2fw - [0:0]                                                                                          
:loc2net - [0:0]                                                                                         
:logdrop - [0:0]                                                                                         
:logflags - [0:0]                                                                                        
:logreject - [0:0]                                                                                       
:net2fw - [0:0]                                                                                          
:net2loc - [0:0]                                                                                         
:reject - [0:0]                                                                                          
:shorewall - [0:0]                                                                                       
:smurfs - [0:0]                                                                                          
:tcpflags - [0:0]                                                                                        
-A INPUT -m state --state INVALID,NEW -j dynamic                                                         
-A INPUT -i eth0 -j net2fw                                                                               
-A INPUT -i eth1 -j loc2fw                                                                               
-A INPUT -i lo -j ACCEPT                                                                                 
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT                                                  
-A INPUT -j Reject                                                                                       
-A INPUT -j LOG --log-prefix "Shorewall:INPUT:REJECT:" --log-level 6                                     
-A INPUT -g reject                                                                                       
-A FORWARD -j LOG --log-prefix "In FORWARD chain: " --log-level 7                                        
-A FORWARD -i eth1 -m mac --mac-source 00:0D:9D:59:9F:71 -j blocked_access                               
-A FORWARD -m state --state INVALID,NEW -j dynamic                                                       
-A FORWARD -i eth0 -o eth1 -j net2loc                                                                    
-A FORWARD -i eth1 -o eth0 -j loc2net                                                                    
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT                                                
-A FORWARD -j Reject                                                                                     
-A FORWARD -j LOG --log-prefix "Shorewall:FORWARD:REJECT:" --log-level 6                                 
-A FORWARD -g reject                                                                                     
-A OUTPUT -o eth0 -j fw2net                                                                              
-A OUTPUT -o eth1 -j fw2loc                                                                              
-A OUTPUT -o lo -j ACCEPT                                                                                
-A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT                                                 
-A OUTPUT -j Reject                                                                                      
-A OUTPUT -j LOG --log-prefix "Shorewall:OUTPUT:REJECT:" --log-level 6                                   
-A OUTPUT -g reject                                                                                      
-A Drop                                                                                                  
-A Drop -p tcp -m tcp --dport 113 -m comment --comment "Auth" -j reject                                  
-A Drop -j dropBcast                                                                                     
-A Drop -p icmp -m icmp --icmp-type 3/4 -m comment --comment "Needed ICMP types" -j ACCEPT               
-A Drop -p icmp -m icmp --icmp-type 11 -m comment --comment "Needed ICMP types" -j ACCEPT                
-A Drop -j dropInvalid                                                                                   
-A Drop -p udp -m multiport --dports 135,445 -m comment --comment "SMB" -j DROP                          
-A Drop -p udp -m udp --dport 137:139 -m comment --comment "SMB" -j DROP                                 
-A Drop -p udp -m udp --sport 137 --dport 1024:65535 -m comment --comment "SMB" -j DROP                  
-A Drop -p tcp -m multiport --dports 135,139,445 -m comment --comment "SMB" -j DROP                      
-A Drop -p udp -m udp --dport 1900 -m comment --comment "UPnP" -j DROP                                   
-A Drop -p tcp -j dropNotSyn                                                                             
-A Drop -p udp -m udp --sport 53 -m comment --comment "Late DNS Replies" -j DROP                         
-A Reject                                                                                                
-A Reject -p tcp -m tcp --dport 113 -m comment --comment "Auth" -j reject                                
-A Reject -j dropBcast                                                                                   
-A Reject -p icmp -m icmp --icmp-type 3/4 -m comment --comment "Needed ICMP types" -j ACCEPT             
-A Reject -p icmp -m icmp --icmp-type 11 -m comment --comment "Needed ICMP types" -j ACCEPT              
-A Reject -j dropInvalid                                                                                 
-A Reject -p udp -m multiport --dports 135,445 -m comment --comment "SMB" -j reject                      
-A Reject -p udp -m udp --dport 137:139 -m comment --comment "SMB" -j reject                             
-A Reject -p udp -m udp --sport 137 --dport 1024:65535 -m comment --comment "SMB" -j reject              
-A Reject -p tcp -m multiport --dports 135,139,445 -m comment --comment "SMB" -j reject                  
-A Reject -p udp -m udp --dport 1900 -m comment --comment "UPnP" -j DROP                                 
-A Reject -p tcp -j dropNotSyn                                                                           
-A Reject -p udp -m udp --sport 53 -m comment --comment "Late DNS Replies" -j DROP                       
-A blocked_access -j LOG --log-prefix "In BLOCKED_ACCESS: " --log-level 7                                
-A blocked_access -m time --timestart 20:19:00 --timestop 20:22:00 --weekdays Sat  -j ACCEPT             
-A blocked_access -j LOG --log-prefix "DROPPED MAC: " --log-level 7                                      
-A blocked_access -j DROP                                                                                
-A dropBcast -m addrtype --dst-type BROADCAST -j DROP                                                    
-A dropBcast -d 224.0.0.0/4 -j DROP                                                                      
-A dropInvalid -m state --state INVALID -j DROP                                                          
-A dropNotSyn -p tcp -m tcp ! --tcp-flags FIN,SYN,RST,ACK SYN -j DROP                                    
-A fw2loc -m state --state RELATED,ESTABLISHED -j ACCEPT                                                 
-A fw2loc -p icmp -j ACCEPT                                                                              
-A fw2loc -p tcp -m tcp --dport 25 -m comment --comment "SMTP" -j ACCEPT                                 
-A fw2loc -j ACCEPT                                                                                      
-A fw2net -p udp -m udp --dport 67:68 -j ACCEPT                                                          
-A fw2net -m state --state RELATED,ESTABLISHED -j ACCEPT                                                 
-A fw2net -p tcp -m tcp --dport 80 -j ACCEPT                                                             
-A fw2net -p udp -m udp --dport 53 -m comment --comment "DNS" -j ACCEPT                                  
-A fw2net -p tcp -m tcp --dport 53 -m comment --comment "DNS" -j ACCEPT                                  
-A fw2net -p icmp -j ACCEPT                                                                              
-A fw2net -p udp -m udp --dport 123 -m comment --comment "NTP" -j ACCEPT                                 
-A fw2net -j ACCEPT                                                                                      
-A loc2fw -m state --state INVALID,NEW -j smurfs                                                         
-A loc2fw -p tcp -j tcpflags                                                                             
-A loc2fw -m state --state RELATED,ESTABLISHED -j ACCEPT                                                 
-A loc2fw -p tcp -m tcp --dport 3128 -m conntrack --ctorigdstport 80 -j ACCEPT                           
-A loc2fw -p udp -m udp --dport 53 -m comment --comment "DNS" -j ACCEPT                                  
-A loc2fw -p tcp -m tcp --dport 53 -m comment --comment "DNS" -j ACCEPT                                  
-A loc2fw -p tcp -m tcp --dport 22 -m comment --comment "SSH" -j ACCEPT                                  
-A loc2fw -p icmp -m icmp --icmp-type 8 -m comment --comment "Ping" -j ACCEPT                            
-A loc2fw -p tcp -m tcp --dport 10000 -m comment --comment "Webmin" -j ACCEPT                            
-A loc2fw -p udp -m udp --dport 123 -m comment --comment "NTP" -j ACCEPT                                 
-A loc2fw -j ACCEPT                                                                                      
-A loc2net -m state --state INVALID,NEW -j smurfs                                                        
-A loc2net -p tcp -j tcpflags                                                                            
-A loc2net -m state --state RELATED,ESTABLISHED -j ACCEPT                                                
-A loc2net -s 192.168.10.22/32 -p tcp -m tcp --dport 25 -m comment --comment "SMTP" -j ACCEPT            
-A loc2net -j ACCEPT                                                                                     
-A logdrop -j DROP                                                                                       
-A logflags -j LOG --log-prefix "Shorewall:logflags:DROP:" --log-level 6 --log-ip-options                
-A logflags -j DROP                                                                                      
-A logreject -j reject                                                                                   
-A net2fw -m state --state INVALID,NEW -j smurfs                                                         
-A net2fw -p udp -m udp --dport 67:68 -j ACCEPT                                                          
-A net2fw -p tcp -j tcpflags                                                                             
-A net2fw -m state --state RELATED,ESTABLISHED -j ACCEPT                                                 
-A net2fw -p udp -m udp --dport 53 -m comment --comment "DNS" -j ACCEPT                                  
-A net2fw -p tcp -m tcp --dport 53 -m comment --comment "DNS" -j ACCEPT                                  
-A net2fw -p icmp -m icmp --icmp-type 8 -m comment --comment "Ping" -j DROP
-A net2fw -p tcp -m tcp --dport 10000 -m comment --comment "Webmin" -j DROP
-A net2fw -j Drop
-A net2fw -j LOG --log-prefix "Shorewall:net2fw:DROP:" --log-level 6
-A net2fw -j DROP
-A net2loc -m state --state INVALID,NEW -j smurfs
-A net2loc -p tcp -j tcpflags
-A net2loc -m state --state RELATED,ESTABLISHED -j ACCEPT
-A net2loc -d 192.168.10.22/32 -p tcp -m tcp --dport 6881:6999 -m comment --comment "BitTorrent32" -j ACCEPT
-A net2loc -d 192.168.10.22/32 -p udp -m udp --dport 6881 -m comment --comment "BitTorrent32" -j ACCEPT
-A net2loc -d 192.168.10.22/32 -p tcp -m tcp --dport 80 -m comment --comment "HTTP" -j ACCEPT
-A net2loc -d 192.168.10.22/32 -p tcp -m tcp --dport 443 -m comment --comment "HTTPS" -j ACCEPT
-A net2loc -d 192.168.10.22/32 -p tcp -m tcp --dport 25 -m comment --comment "SMTP" -j ACCEPT
-A net2loc -j Drop
-A net2loc -j LOG --log-prefix "Shorewall:net2loc:DROP:" --log-level 6
-A net2loc -j DROP
-A reject -m addrtype --src-type BROADCAST -j DROP
-A reject -s 224.0.0.0/4 -j DROP
-A reject -p igmp -j DROP
-A reject -p tcp -j REJECT --reject-with tcp-reset
-A reject -p udp -j REJECT --reject-with icmp-port-unreachable
-A reject -p icmp -j REJECT --reject-with icmp-host-unreachable
-A reject -j REJECT --reject-with icmp-host-prohibited
-A smurfs -s 0.0.0.0/32 -j RETURN
-A smurfs -m addrtype --src-type BROADCAST -j LOG --log-prefix "Shorewall:smurfs:DROP:" --log-level 6
-A smurfs -m addrtype --src-type BROADCAST -j DROP
-A smurfs -s 224.0.0.0/4 -j LOG --log-prefix "Shorewall:smurfs:DROP:" --log-level 6
-A smurfs -s 224.0.0.0/4 -j DROP
-A tcpflags -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG FIN,PSH,URG -j logflags
-A tcpflags -p tcp -m tcp --tcp-flags FIN,SYN,RST,PSH,ACK,URG NONE -j logflags
-A tcpflags -p tcp -m tcp --tcp-flags SYN,RST SYN,RST -j logflags
-A tcpflags -p tcp -m tcp --tcp-flags FIN,SYN FIN,SYN -j logflags
-A tcpflags -p tcp -m tcp --sport 0 --tcp-flags FIN,SYN,RST,ACK SYN -j logflags
COMMIT
# Completed on Sat Feb  6 20:26:41 2010
 
Old 02-06-2010, 10:23 PM   #7
nimnull22
Senior Member
 
Registered: Jul 2009
Distribution: OpenSuse 11.1, Fedora 14
Posts: 1,554

Rep: Reputation: 89
OK, i will try to summarize, you check, because rules are complicated. I have no idea why. Anyway, according to your rules: FORWARD -i eth1, packets enter from ETH1. So:
First table MANGLE:
1. -A PREROUTING -j tcpre
I did not find that chain any more, so please check.

Second table NAT:
1. PREROUTING -j dnat
2. dnat -i eth1 -j loc_dnat
3. IF loc_dnat -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 3128, if not go to FORWARD chain.

Third FORWARD:
MANGLE forward:
1. -A FORWARD -j MARK --set-xmark 0x0/0xffffffff
2. -A FORWARD -j tcfor = I did not find that chain any more, so please check.
FILTER forward:
1. FORWARD -j LOG --log-prefix "In FORWARD chain: " --log-level 7
2. FORWARD -i eth1 -m mac --mac-source 00:0D:9D:59:9F:71 -j blocked_access

blocked_access -j LOG --log-prefix "In BLOCKED_ACCESS: " --log-level 7
blocked_access -m time --timestart 20:19:00 --timestop 20:22:00 --weekdays Sat -j ACCEPT

And here if "--timestart 20:19:00 --timestop 20:22:00 --weekdays Sat" we ACCEPT forward that packets.
If not, then go to
blocked_access -j LOG --log-prefix "DROPPED MAC: " --log-level 7
blocked_access -j DROP

If my thoughts are right, and you got at Feb 6 17:29:28
In FORWARD chain: IN=eth1 SRC=192.168.10.186 DST=74.125.95.106 ID=14942
In BLOCKED_ACCESS: IN=eth1 OUT=eth0 SRC=192.168.10.186 DST=74.125.95.106 ID=14942
DROPPED MAC: IN=eth1 OUT=eth0 SRC=192.168.10.186 DST=74.125.95.106 ID=14942

Everything works well, because "Feb 6 17:29:28" is not within "--timestart 20:19:00 --timestop 20:22:00"

Check this please, I can be wrong.
Thanks
 
Old 02-09-2010, 03:25 AM   #8
ScottSmith
LQ Newbie
 
Registered: Mar 2004
Distribution: Debian - Sid
Posts: 22

Original Poster
Rep: Reputation: 1
Sorry for the long delay in responding.


I must have gotten my log files crossed with a different run. Sorry for the confusion.

The problem that I was having was issuing the command

Code:
-A blocked_access -m time --timestart 20:19:00 --timestop 20:22:00 --weekdays Sat  -j ACCEPT
I would test that the connect was working before issuing the command, and it was. I would then issue the command and test the connection again.

If the time was 20:18 or 20:23 the connection was blocked, as it should be. However, the problem was when the time was 20:20 and the connection was still blocked. As you can see from ACCEPT rule; the pkts/bytes counter is still zero.
Code:
Chain blocked_access (1 references)
 pkts bytes target     prot opt in     out     source               destination
   33  1488 LOG        all  --  *      *       0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 7 prefix `In BLOCKED_ACCESS: '
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           TIME from 17:09:00 to 17:11:00 on Sat
   33  1488 LOG        all  --  *      *       0.0.0.0/0            0.0.0.0/0           LOG flags 0 level 7 prefix `DROPPED MAC: '
   33  1488 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0
I appears to me that ACCEPT rule was being skipped and the packets fell through to the DROP rule. As I said earlier this is my first attempt at writing a iptable rule.

What I ended up doing was writing two scripts. The first is used to insert a rule that matches on the MAC address then drops the packet if there is a match. The second rule is used to delete the same rule. I then use a cron job to run the two scripts at the appropriate times. I hope this just a band aide until I can get some reading/research under my belt.

I would like to thanks you for taking the time answer my question and providing some advice.

Take care

Scott

Last edited by ScottSmith; 02-09-2010 at 03:26 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Samba: How to restrict access to server via MAC-address? johnny1959 Linux - Networking 5 03-27-2008 05:43 AM
iptables based on MAC address shrinivas.bura Linux - General 1 11-16-2006 12:18 AM
by using iptables block mac address to restric user to access internet Farrukh Fida Linux - Networking 3 10-09-2006 08:59 AM
restrict server access by mac address? stinkpot Linux - Software 4 11-22-2005 08:05 AM
iptables : Restrict access at certain times of day J-Ben Linux - Newbie 1 03-28-2004 10:38 PM


All times are GMT -5. The time now is 10:04 AM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration