LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 03-25-2009, 09:24 AM   #1
lightwing
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Rep: Reputation: 0
iptables rules for web server email server,ftp and ssh,please help


I'm a linux newbie.
My company has a server, it runs apache,mysql,qmail and ftp.
Now I want to set up iptables rules to protect it.
I want to hide the port of mysql, so that the user from internet cannot connect to mysql. Other services can be connect from internet.

And I also want to block clients who open new connections more than 500 in 10 seconds for 1 hours. Will this rule affect search engineer spider to search my website?

Please kindly help me to check whether rules i set could do what I want or not.
The following are my iptables rules:

IPTABLES= /sbin/iptables

/sbin/depmod -a

/sbin/modprobe ip_tables
/sbin/modprobe ip_conntrack
/sbin/modprobe iptable_filter
/sbin/modprobe iptable_managle
/sbin/modprobe iptable_nat
/sbin/modprobe ipt_state
/sbin/modprobe ipt_limit

$IPTABLES -t filter -P INPUT -p ALL -j DROP
$IPTABLES -t filter -P FORWARD -p ALL -j DROP
$IPTABLES -t filter -P OUTPUT -p ALL -j ACCEPT

$IPTABLES -N ratelimit

$IPTABLES -A OUTPUT -p tcp --sport 31337:31340 -j DROP
$IPTABLES -A OUTPUT -p tcp --dport 31337:31340 -j DROP

# SSH: 22, FTP: 21, http: 80, https:443, smtp:110, pop3:25, imap: 143
$IPTABLES -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
$IPTABLES -t filter -A INPUT -m state --state NEW -p tcp -m recent --update -- rsource --secnods 10 --hitcount 50 -j DROP
$IPTABLES -t filter -A INPUT -m state --state NEW -p tcp -m recent --set -- rsource -j ACCEPT
$IPTABLES -t filter -A INPUT -p tcp --syn -m multiport --dport 80,143,443,21,22,25,110 -j ratelimit

$IPTABLES -A ratelimit -p tcp -m state NEW -m recent --update --rsource --seconds 3600 -j DROP
$IPTABLES -A ratelimit -p tcp -m state --state NEW -m hashlimit --hashlimit 10/sec --haslimit-burst 50 --hashlimit-mode dstip --hashlimit-name badguy -j return

Regards &Thanks in advance
 
Old 03-25-2009, 08:58 PM   #2
lightwing
LQ Newbie
 
Registered: Mar 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Anyone here?
 
  


Reply



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
How to monitor web server, FTP server, Mail server and database server vodka33us Programming 1 06-16-2008 04:20 AM
Web email server from private email server guy_ripper Linux - Server 2 01-17-2008 06:58 AM
iptables for home mail/web/ftp server Z038 Linux - Server 5 05-24-2007 06:34 PM
[IPTABLES] open ext access to web server on GW server kozaki Linux - Networking 3 08-27-2005 05:11 PM
Setup a linux server, DNS, WEB, FTP, and Mail Server Help watermelon_lee Linux - Networking 1 08-26-2003 03:09 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:58 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