Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
12-06-2005, 05:18 PM
|
#1
|
LQ Newbie
Registered: Dec 2005
Posts: 18
Rep:
|
New Firewall - SYN Flood
Hi all,
I have been given a class project to install a firewall on a Linux machine and to try to prevent a SYN Flood attack. I have no previous Linux experience or firewall experience prior to this project. Can someone please help me out....
I've installed about 4 different firewalls but do not know how to configure them properly. I don't know how to modify a firewall's policy to protect againsy a syn attack. I appreciate any help.
Thanks,
Craig
|
|
|
12-06-2005, 05:48 PM
|
#2
|
Member
Registered: Sep 2002
Posts: 310
Rep: 
|
We won't do your homework for you, so try breaking it down to more specific questions. First think about what a SYN flood is and how you would prevent it. What is going on? What can you do? Then search for how to do it. There are several methods for attempting to prevent a SYN flood attack. Therefore you should have several ideas about the matter.
|
|
|
12-07-2005, 04:05 AM
|
#3
|
LQ Newbie
Registered: Dec 2005
Distribution: Slackware, Mandrake
Posts: 15
Rep:
|
Just to give some more hints in the direction
1. dont try to install different firewalls..basically any firewall will do IF u know wht u want to exactly configure
2. As said by GNUBie, try to find out exactly wht a SYN flood attack is.
3. Try to learn how to add simple firewall rules [in case u havent decided wht to use, start reading up on IPTABLES. In linux that shud be more than enough for u]
all the best, and keep posting things as u get stuck..we will then help u..
|
|
|
12-07-2005, 11:01 AM
|
#4
|
LQ Newbie
Registered: Dec 2005
Posts: 18
Original Poster
Rep:
|
Ok, here's what's up.
I'm not asking for my homework to be done but I understand how my question may have come across.
I know how a syn flood is carried out to an extent. I know that syn packets kept getting sent and no complete connection can be made.
I have a firewall installed (Firestarter) but I can only block ports and ip addresses. I know that I need to watch the packets that come in to look for a syn flag.
The problem is that I don't understand how to set a firewall to block those packets that have a syn flag. I've read stuff about iptables but I don't believe I am proficient enough with Linux to manipualate the files or move around. I have tried alot of different firewalls but most of them are command line based and I don't know enough.
So, I am looking for a little guidance. I appreciate any help you can offer. Again, I don't want you to do my homework for me but I would appreciate some guidance. Thanks...
|
|
|
12-07-2005, 11:39 AM
|
#5
|
LQ Newbie
Registered: Dec 2005
Posts: 18
Original Poster
Rep:
|
One more question...
How do I view the iptables rules file? (Location?)
And how do I modify these rule codes to add some of my own?
Remember, I'm fairly new to Linux.
Thanks...
|
|
|
12-07-2005, 11:50 AM
|
#6
|
LQ Newbie
Registered: Dec 2005
Posts: 18
Original Poster
Rep:
|
Sorry to keep posting but I think I'm getting closer to a solution. I found some code and listed it below. What file would I place this in and does it matter what order it would go in? Thanks...
iptables -A INPUT -p tcp --syn -m limit --limit 1/s -j ACCEPT
iptables -N SYN_FLOOD
iptables -A SYN_FLOOD -p tcp --syn =synopt -j RETURN
iptables -A SYN_FLOOD -p ! tcp -j RETURN
iptables -A SYN_FLOOD -p tcp ! --syn -j RETURN
iptables -A SYN_FLOOD -j LOG --log-prefix "IPT SYN_FLOOD: " =logopt
iptables -A SYN_FLOOD -j DROP
|
|
|
12-07-2005, 02:21 PM
|
#7
|
Member
Registered: Sep 2002
Posts: 310
Rep: 
|
Those are commands that can be run as root. So you could login as root and enter each of those at the console, or you could put them all in a file (script) and execute that. I would do the latter.
1. Create script
Code:
cat > /usr/local/src/syn_flood.sh
#!/bin/bash
iptables -A INPUT -p tcp --syn -m limit --limit 1/s -j ACCEPT
iptables -N SYN_FLOOD
iptables -A SYN_FLOOD -p tcp --syn =synopt -j RETURN
iptables -A SYN_FLOOD -p ! tcp -j RETURN
iptables -A SYN_FLOOD -p tcp ! --syn -j RETURN
iptables -A SYN_FLOOD -j LOG --log-prefix "IPT SYN_FLOOD: " =logopt
iptables -A SYN_FLOOD -j DROP
* hit enter after your last line, then ctrl+c to finish
2. Make script executable
Code:
chmod 711 /usr/local/src/syn_flood.sh
3. Execute script
Code:
/usr/local/src/syn_flood.sh
4. View iptables rules
|
|
|
12-07-2005, 09:51 PM
|
#8
|
LQ Newbie
Registered: Dec 2005
Distribution: Slackware, Mandrake
Posts: 15
Rep:
|
you are doing real good. Let me tell you something. Look up at the limit module in iptables. Basically the problem is that if you decide to DROP any SYN packet, then you will not be able to do anything productive. Hence you have to rate-limit the packet. Depending on your usage, you decide to allow some X SYN packets per second and anything more than that, you say that this could be a scan. No one will be able to decide a "correct" value for X, because there is nothing such as a "correct" value.
So all the best!
|
|
|
12-08-2005, 08:12 AM
|
#9
|
LQ Newbie
Registered: Dec 2005
Posts: 18
Original Poster
Rep:
|
Which of these codes do you think I should use? And what is the difference with the eth0?
#Syn flood protection
iptables -N syn-flood
iptables -A INPUT -p tcp --syn -j syn-flood
iptables -A syn-flood -m limit --limit 1/s --limit-burst 4 -j RETURN
iptables -A syn-flood -j DROP
#Make sure new TCP connections are syn packets
iptables -A INPUT -p tcp ! --syn -m state --state NEW -j DROP
#Syn flood protection
iptables -N syn-flood
iptables -A INPUT -i eth0 -p tcp --syn -j syn-flood
iptables -A syn-flood -m limit --limit 1/s --limit-burst 4 -j RETURN
iptables -A syn-flood -j DROP
#Make sure new TCP connections are syn packets
iptables -A INPUT -i eth0 -p tcp ! --syn -m state --state NEW -j DROP
Can you tell me if I am right when I try to explain what happens. Is it saying that it is only going to allow 4 syn packets per second? And if so do you think this is sufficient enough?
Thanks for the help all...
|
|
|
12-10-2005, 06:12 PM
|
#10
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
also, consider using TCP SYN cookies...
Code:
echo "1" > /proc/sys/net/ipv4/tcp_syncookies
http://www.google.com/linux?&q=tcp_syncookies
|
|
|
12-11-2005, 12:50 PM
|
#11
|
Member
Registered: Aug 2003
Location: Canada/US
Distribution: Ubuntu, Arch
Posts: 84
Rep:
|
All -i eth0 means, is that you specify which network interface you want this rule to apply to. If you had more than one network card, you can make your rules more specific and flexible by specifying eth0, eth1 etc.
|
|
|
12-12-2005, 01:20 AM
|
#12
|
LQ Newbie
Registered: Dec 2005
Distribution: Slackware, Mandrake
Posts: 15
Rep:
|
or you could make it more generic with
this would be a regular expression that accepts any interface like eth0, eth1, etc (1 character indicated by a +)
|
|
|
12-12-2005, 12:11 PM
|
#13
|
LQ Newbie
Registered: Dec 2005
Posts: 18
Original Poster
Rep:
|
How do I know if it is working? I am running the syn flood on one computer and running these commands but it is still bogging down the machine. Is there a log file or something I can see to find out if it is working? Thanks
|
|
|
12-12-2005, 12:16 PM
|
#14
|
LQ Newbie
Registered: Dec 2005
Posts: 18
Original Poster
Rep:
|
Also, the machine I am running the syn flood from has the address 192.168.1.1 because it's through a router. Also, the syn flood code is set up so that it spoofs the ip address so that I get 192.168.1.* where * is anything. 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
|
|
|
12-12-2005, 12:17 PM
|
#15
|
LQ Guru
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870
|
are you using the syn cookies??
|
|
|
All times are GMT -5. The time now is 04:16 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|