LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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
  Search this Thread
Old 12-12-2005, 12:20 PM   #16
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380

Quote:
Originally Posted by kriggo15
How do I block everything from 192.168.1.*? I know that iptables doesn't accept that wildcard and I don't want to have to type in the command in 255 times to block all of the addresses. thanks
specify the entire subnet as a source... like:
Code:
192.168.1.0/24
but still, remember that limiting SYN packets with the general limit rules you posted is gonna affect them all, including the ones that aren't part of the flood...

Last edited by win32sux; 12-12-2005 at 12:25 PM.
 
Old 12-12-2005, 12:53 PM   #17
kriggo15
LQ Newbie
 
Registered: Dec 2005
Posts: 18

Original Poster
Rep: Reputation: 0
I used the
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
command.

I'm am just so lost and confused right now. Here is my setup. I have one computer that has the iptables running on it along with a server and a few test pages. I have another computer that is running the syn flood attack. I have a third computer that is accessing the server and trying to get access to the webpages. All of the computers are hooked up through a router.

Does anyone have any advice?

Also, can someone tell me where I can view the configuration file for iptables in red hat?

Thanks everyone...
 
Old 12-12-2005, 01:05 PM   #18
kriggo15
LQ Newbie
 
Registered: Dec 2005
Posts: 18

Original Poster
Rep: Reputation: 0
I just viewed my configuration file and this is what it looks like:

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT- [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 23 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT


can someone please help me configure this thing.
 
Old 12-12-2005, 01:09 PM   #19
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by kriggo15
I used the
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
command.
AFAIK if you use that command along with the general SYN packet limit rules, then you'd still be limiting SYN packets for non-flood connections - so the server would still appear sluggish to the clients trying to establish normal connections... try using the tcp_syncookies without using the limiting SYN packet rules...

Quote:
Also, can someone tell me where I can view the configuration file for iptables in red hat?
i'm not sure where it's stored in redhat (just google it), but you can store them wherever you want when you run the iptables-save command... and you can then pick-them-up with the iptables-restore command... if you want to look at your *current* configuration just run a command like:
Code:
iptables -L
 
Old 12-12-2005, 01:13 PM   #20
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
BTW: if the "syn flood generator" and the web server are on the same LAN then it really doesn't matter what you do on the router/firewall... you need to have the two boxes on separate networks for the simulation to work (if you are doing this on the router)...

also, why is your INPUT policy set to ACCEPT?? same question for the FORWARD chain...

Last edited by win32sux; 12-12-2005 at 01:15 PM.
 
Old 12-12-2005, 01:15 PM   #21
kriggo15
LQ Newbie
 
Registered: Dec 2005
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by win32sux
BTW: if the syn-flood-generator and the web server are on the same LAN then it really doesn't matter what you do on the router/firewall... you need to have the two boxes on separate networks for the simulation to work...

could you explain why this is? It's obvious that you know more than I do so I would like to understand. thanks...
 
Old 12-12-2005, 01:37 PM   #22
kriggo15
LQ Newbie
 
Registered: Dec 2005
Posts: 18

Original Poster
Rep: Reputation: 0
I'm not sure why the input and forward chains are set to accept. This is the initial setup configuration on this computer. What should it be set to?
 
Old 12-12-2005, 02:20 PM   #23
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by kriggo15
could you explain why this is?
because by nature a firewall/router can only filter traffic BETWEEN networks... machines on the same LAN do not need to send packets through a router in order to communicate, they can do so directly... in practical terms, boxes on a lan only rely on the switch/hub for communication (and on their local firewall rules)... the router is only needed to deal with traffic between the LAN and another network, such as another LAN or the Internet...

Quote:
Originally Posted by kriggo15
I'm not sure why the input and forward chains are set to accept. This is the initial setup configuration on this computer. What should it be set to?
it should be set to DROP...
Code:
iptables -P INPUT DROP
iptables -P FORWARD DROP
having the policy set to DROP, then you only need to add rules for the packets you actually want to ACCEPT... anything that doesn't get ACCEPTed will hit the default policy of DROP...

Last edited by win32sux; 12-12-2005 at 02:21 PM.
 
Old 12-12-2005, 05:05 PM   #24
kriggo15
LQ Newbie
 
Registered: Dec 2005
Posts: 18

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by kriggo15
*filter
:INPUT DROP [0:0]
:FORWARD DROP [0:0]
:OUTPUT ACCEPT [0:0]
:RH-Firewall-1-INPUT- [0:0]
-A INPUT -j RH-Firewall-1-INPUT
-A FORWARD -j RH-Firewall-1-INPUT
-A RH-Firewall-1-INPUT -i lo -j ACCEPT
-A RH-Firewall-1-INPUT -i eth0 -j ACCEPT
-A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
-A RH-Firewall-1-INPUT -p 50 -j ACCEPT
-A RH-Firewall-1-INPUT -p 51 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 443 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 21 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 22 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 23 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -dport 25 -j ACCEPT
-A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
COMMIT

echo "1" > /proc/sys/net/ipv4/tcp_syncookies
so should my configuration look like this?
 
Old 12-12-2005, 07:14 PM   #25
kriggo15
LQ Newbie
 
Registered: Dec 2005
Posts: 18

Original Poster
Rep: Reputation: 0
I asked my teacher about the connection between the computers and this is what he said:

"This talks about the firewall on the router. In your case, the firewall
is on the end server, for example, IPtables, which manages every packet
in or out the server. This kind of firewall still works even when
attackers are in the same LAN."

What kind of packets do I need to accept? Thanks for all of the help by the way
 
Old 12-12-2005, 07:30 PM   #26
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Quote:
Originally Posted by kriggo15
I asked my teacher about the connection between the computers and this is what he said:

"This talks about the firewall on the router. In your case, the firewall
is on the end server, for example, IPtables, which manages every packet
in or out the server. This kind of firewall still works even when
attackers are in the same LAN."
yup, your teacher is right... but this was stated here before, in post #23:
Quote:
Originally Posted by win32sux
boxes on a lan only rely on the switch/hub for communication (and on their local firewall rules)...
 
Old 12-12-2005, 07:48 PM   #27
kriggo15
LQ Newbie
 
Registered: Dec 2005
Posts: 18

Original Poster
Rep: Reputation: 0
what packets do I need to let through and do i need give them any specific permissions?
 
Old 12-12-2005, 08:39 PM   #28
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
if it's strictly an HTTP server then basically you just need to allow TCP packets destined to port 80... if it's also HTTPS then add a rule for TCP port 443... sorry i can't be more specific right now, i'm kinda in the middle of something... i'm sure someone else will jump in...
 
Old 12-14-2005, 09:39 PM   #29
kriggo15
LQ Newbie
 
Registered: Dec 2005
Posts: 18

Original Poster
Rep: Reputation: 0
If I wanted to accept the address 192.168.1.20, how would I write the rule? Also, if I write this at the very top of my rules, would it be executed first?

Also, if I wanted to block all ip addresses other than the 192.168.1.20 address (192.168.1.1-19,21-255) how would I write that rule?

Thanks in advance
 
Old 12-14-2005, 11:15 PM   #30
dsumedh
LQ Newbie
 
Registered: Dec 2005
Distribution: Slackware, Mandrake
Posts: 15

Rep: Reputation: 0
AFAIK you can specify a mask in iptables,
say
Code:
192.168.10.0/255.255.255.0
this will solve your problem of giving a range/same address 255 times!
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
SYN flood 98steve600 Linux - General 1 03-28-2005 03:27 AM
SYN flood with Game Empowerer Linux - Networking 3 07-25-2004 04:36 PM
Syn Flood Attack Detect synaptical Linux - Security 2 07-25-2004 01:48 PM
protection from SYN flood attacks chenkoforever Linux - Security 4 06-22-2004 05:38 PM
Can't SYN Flood a Linux jveron23 Linux - Security 3 10-06-2003 11:27 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 11:39 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration